Y-axis labels overlaps with figure when using a reversed x-axis
3 views (last 30 days)
Show older comments
Heya,
In Matlab 2018B, when plotting data with a reversed x-axis, the y-axis ticks and labels appear over the figure in a nasty fashion.
Minimal example:
figure(1);
plot(gca,0:10,(0:10).^10);
set(gca,'xdir','reverse')
Is there a way to force an offset? Or to fix it in another way?
0 Comments
Answers (2)
David Wilson
on 11 Apr 2019
Edited: David Wilson
on 11 Apr 2019
Yes, it seems to only happen when there is an exponent in the y-axis. And even then the exponent must have double figures. Also the same happens (on the x-axis) when reversing the y-axis.
One really ugly fix is to extract the ylabels and pad them with a few spaces (on the right).
hp = plot(gca,0:10,(0:10).^10);
set(gca,'xdir','reverse')
yt = yticklabels;
for i=1:length(yt)
yt{i} = [yt{i},' ']; % note pad with a few spaces
end
yticklabels(yt)
Plot now looks like
David Wilson
on 11 Apr 2019
Ah, missed that. Nasty bug/feature.
text(10,10.5e9,'x10^9') % place manually ?
0 Comments
See Also
Categories
Find more on Axis Labels in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!