Misalignment between subplots when plotting with logarithmic scale

조회 수: 1 (최근 30일)
yonatan s
yonatan s 2021년 2월 18일
댓글: yonatan s 2021년 2월 18일
Hi,
I plot two subplots, but their y-axis (which I want to be logarithmic) is not aligned between the two.
Sample code:
ax(1)=subplot(1,2,1);
semilogy(1:10,1:10,'x');
grid minor;
ax(2)=subplot(1,2,2);
semilogy([1:10]/2,[1:10]/2,'x');
grid minor;
set(ax,'YLim',[0 10],'XLim',[0 10])
ax(1).YTick = ax(2).YTick;
ax(1).YTickLabel = ax(2).YTickLabel;
The same behaviour is seen when I use the regular plot/scatter functions and then set the y-axis to log scale.
I also tried linkaxes - failed as well.
  댓글 수: 1
yonatan s
yonatan s 2021년 2월 18일
Okay I got it. Because it is log-scale setting YLim(1) to 0 is problematic. Upon setting it on a small value instead the issue is fixed.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by