Xaxis log scale labels overlapping with yaxis labels

15 views (last 30 days)
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 Comment
Adam Danz
Adam Danz on 12 Sep 2020
What about setting ylim() so that there's a bit more space at the top after y=0?

Sign in to comment.

Answers (1)

Ameer Hamza
Ameer Hamza on 13 Sep 2020
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 Comments
Kelly Biagi
Kelly Biagi on 20 Oct 2020
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 on 20 Oct 2020
In that case, you can try the following
ax = gca;
ax.XAxis.TickLabelGapOffset = 5

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!