Last tick labels dissapear when plotting with axes at origin (0,0)
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I'm trying to plot a line that has negative and positive x and y values, and therefore would like to include an axes through the origin. When plotting however, the last tick labels from the x and y axes dissapear. Within the window, I can drag the graph left/right or up/down, and the labels reappear, but in the direction I dragged to. The window essentially does not allow the ticks to be displayed. Is there a way I can force the ticks to display over the window? I can force the labels to appear If i slightly increase xlim and ylim, but then I have some of the grid appearing which is annoying. See pics attached.


0 Commenti
Risposta accettata
Star Strider
il 20 Ago 2025
After experimenting with this a bit, using:
axis('padded')
might be the best option.
x = linspace(-20, 20, 50);
y = tanh(x/10)/5;
figure
plot(x, y, 'x-')
grid
Ax = gca;
Ax.XAxisLocation = 'origin';
Ax.YAxisLocation = 'origin';
% Ax.XTick = -20:5:20;
% Ax.YTick = -0.2:0.05:0.2;
% axis([-21 21 -0.21 0.21])
axis('padded')
There might also be other options.
.
2 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
