Xaxis log scale labels overlapping with yaxis labels

8 Ansichten (letzte 30 Tage)
Kelly Biagi
Kelly Biagi am 12 Sep. 2020
Kommentiert: Ameer Hamza am 20 Okt. 2020
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 Kommentar
Adam Danz
Adam Danz am 12 Sep. 2020
What about setting ylim() so that there's a bit more space at the top after y=0?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Ameer Hamza
Ameer Hamza am 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 Kommentare
Kelly Biagi
Kelly Biagi am 20 Okt. 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 am 20 Okt. 2020
In that case, you can try the following
ax = gca;
ax.XAxis.TickLabelGapOffset = 5

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Log Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by