Remove or hide the special Y-axis label
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Lupin Remus
el 24 de Abr. de 2019
Comentada: Steven Lord
el 24 de Abr. de 2019
I have generated some sample data. These are probabilities. My problem with the graphics is that 1.01 is displayed on the Y-axis. But there is no probability that is 1.01. Nevertheless I would like to have this free place. Because if the scaling only goes to 1, then the dots are right at the bottom of the graph, which does not look that good.
Here is my code example:
clear all
clc
x = 2:1:7
y = [1 0.945312500000000 0.961318969726563 0.999182315543294 0.996585680786799 0.999999999320726]
plot(x,y,'o','MarkerSize',5,...
'MarkerEdgeColor','b',...
'MarkerFaceColor','c')
axis([0 8 0.94 1.01])
grid on
0 comentarios
Respuesta aceptada
Star Strider
el 24 de Abr. de 2019
Change your axis call to:
axis([0 8 0.94 1])
That should do what you want.
7 comentarios
Star Strider
el 24 de Abr. de 2019
Your 'XTick' values only go from 0 to 8 since you coded them as such. However if you want to use [0 3 6 9], this will plot part of them:
xtix = [0 3 6 9];
set(gca, 'YTick',yt(1:end-1), 'YTickLabel',sprintfc('%.2f',yt(1:end-1)), 'XTick',xtix)
Otherwise, do the same as I did with the 'YTick' and 'YTickLabel' variables to put and name the x-ticks as you like, or change your axis call to go from 0 to 9 on the x-axis.
Steven Lord
el 24 de Abr. de 2019
FYI as of release R2016b there are functions xticks, xticklabels, and xtickformat (as well as the corresponding Y and Z axis versions) to help make this type of customization task easier.
Más respuestas (0)
Ver también
Categorías
Más información sobre Formatting and Annotation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!