Xaxis log scale labels overlapping with yaxis labels

조회 수: 7 (최근 30일)
Kelly Biagi
Kelly Biagi 2020년 9월 12일
댓글: Ameer Hamza 2020년 10월 20일
I can't seem to get my xaxis labels to not overlap with the top of my yaxis labels when I use a log scale on the xaxis with exponents (see figure). I've tried manually setting the axis labels but that doesn't work. I basically want to move the xaxis labels upwards so they are above the Xticks. Any help is appreciated!
plot(Peat.Ksat,Peat.Depth,'ko','MarkerSize',10,'MarkerFaceColor',[0.4 0.4 0.4])
text(1.1E-6,0.29,'n = 36','fontsize',20)
box on
set(gca, 'YDir','reverse')
set(gca, 'XAxisLocation', 'top')
set(gca, 'TickDir','in');
set(gca, 'XScale', 'log')
xlabel('Ksat (m/s)','FontSize',20)
ylabel('Depth (m)','FontSize',20)
print(gcf,'/Users/Kelly/Dropbox/Documents/MATLAB/PhD/Figures/Soil Data/Profile/Peat/Ksat','-djpeg','-r300')
  댓글 수: 1
Adam Danz
Adam Danz 2020년 9월 12일
What about setting ylim() so that there's a bit more space at the top after y=0?

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

답변 (1개)

Ameer Hamza
Ameer Hamza 2020년 9월 13일
Try to set the position y-position of the XLabels manually. For example
ax = gca;
ax.XLabel.Position(2) = -0.02; % -0.02 is location on y-axis
  댓글 수: 5
Kelly Biagi
Kelly Biagi 2020년 10월 20일
All labels look great until I add set(gca, 'XScale','log'). Seems to be something with the log scale even when I set the positions and labels manually.
Ameer Hamza
Ameer Hamza 2020년 10월 20일
In that case, you can try the following
ax = gca;
ax.XAxis.TickLabelGapOffset = 5

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by