How to select first entry of multiple xlim

조회 수: 3 (최근 30일)
Henrik Schädlich
Henrik Schädlich 2017년 11월 15일
이동: VBBV 2025년 5월 28일
Hello,
imagine I have subplots like
for i=1:2
ax = subplot(1,2,i)
xlim(ax(1),[0 130])
xlim(ax(2),[0 140])
end
How can I select only the first xlim entry of ax(1)? I tried this command:
x1 = xlim(ax(1),1); and several other combinations. Best regards Henrik
  댓글 수: 1
Jan
Jan 2017년 11월 15일
The question is not clear. After ax = subplot(1,2,i), ax is a scalar, such that "ax(2)" should fail.

댓글을 달려면 로그인하십시오.

답변 (1개)

Jan
Jan 2017년 11월 15일
편집: Jan 2017년 11월 15일
Perhaps you mean:
for i=1:2
ax = subplot(1,2,i)
axLim = get(ax, 'XLim');
x1 = axLim(1);
end
Or do you want to set the left X-limit keeping the automatic limit on the right?
for i=1:2
ax = subplot(1,2,i)
axLim = get(ax, 'XLim');
xlim(ax, [130, axLim(2)]);
end
  댓글 수: 1
VBBV
VBBV 2025년 5월 28일
이동: VBBV 2025년 5월 28일
Use the for loop index
for i=1:2
ax(i) = subplot(1,2,i)
end
ax =
Axes with properties: XLim: [0 1] YLim: [0 1] XScale: 'linear' YScale: 'linear' GridLineStyle: '-' Position: [0.1300 0.1100 0.3347 0.8150] Units: 'normalized' Use GET to show all properties
ax =
1×2 Axes array: Axes Axes
xlim(ax(1),[0 130]);
xlim(ax(2),[0 140]);

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 NaNs에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by