Y-axis labels overlaps with figure when using a reversed x-axis
Mostrar comentarios más antiguos
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?
Respuestas (2)
David Wilson
el 11 de Abr. de 2019
Editada: David Wilson
el 11 de Abr. de 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

1 comentario
Attila Fülöp
el 11 de Abr. de 2019
David Wilson
el 11 de Abr. de 2019
Ah, missed that. Nasty bug/feature.
text(10,10.5e9,'x10^9') % place manually ?
Categorías
Más información sobre Axis Labels en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!