How to add yTickLabels to multi plot graph?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Mark Golberg
el 18 de Dic. de 2016
Comentada: Star Strider
el 19 de Dic. de 2016
Hello, please have a look at the attached pic. I have 25 plots, drawn on 1 figure (you can 25 raws...)
In the bottom-left corner, I've added with Paint, numbers (1,2,3,4,...).
Question is: how can I add this in Matlab without destroying my y Axis values? (what you can there as 50,100,150...)
Thanks
0 comentarios
Respuesta aceptada
Star Strider
el 18 de Dic. de 2016
See the documentation on Axes Properties (link), particularly XTick (link) and XTickLabel (link). (I know you’re doing y-ticks, but it works the same for both.)
6 comentarios
Star Strider
el 19 de Dic. de 2016
My pleasure.
You just have to experiment with the spacing of your plots in the figure window. You can probably create a function file from my code, and then just call it with the appropriate arguments for each plot.
‘I assume, it is possible to create this new labels bar outside of my figure, to the left of the yTicks, right?’
You assume incorrectly. To the best of my knowledge, you cannot plot outside the plot box. You can see this by changing the axis call in my code to:
axis([0.6 1 0 1])
The line disappears.
I would create two separate y-axes with my code, then turn the default y-axis off. See Axes Properties for details on how to do that. It’s not technically difficult, but does involve programming and experimentation, so make time for that.
Más respuestas (1)
Steven Lord
el 18 de Dic. de 2016
Why not just add ticks at 1, 2, 3, 4, etc. in addition to those that already exist? Change the YTick property of the axes to do that.
3 comentarios
Steven Lord
el 19 de Dic. de 2016
Nothing says that ticks must be equally spaced.
x = 1:10;
y = x.^2;
h = plot(x, y);
ax = ancestor(h, 'axes');
% Look at the ticks on the axes before running the next line
ax.YTick = y;
Nothing says that the tick labels must be the same as the tick values, either.
r = randperm(10) % Arbitrary values
labels = arrayfun(@num2str, r, 'UniformOutput', false);
ax.YTickLabel = labels;
Ver también
Categorías
Más información sobre Grid Lines, Tick Values, and Labels 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!