How to create a uniform y-tick interval in subplots

15 visualizaciones (últimos 30 días)
Richard Rees
Richard Rees el 23 de Mzo. de 2020
Comentada: Richard Rees el 24 de Mzo. de 2020
Hello, I am wondering how to create a uniform y tick interval between subplots in matlab, that takes into consideration the ylimits?
Lets say that I only wanted there to be only 4 intervals per plot and only rounded ytick labels apparement, all the precise same position per subplot. I tried to do this calculating the min and max's for each subplot and dividng the absolute difference between each by 4, unfortunately it didn't work out. Below is the graph that is created without any interference by myself. If anyone is familar with TecPlot, I want to make the axis values 'nice'.
  1 comentario
Stijn Haenen
Stijn Haenen el 23 de Mzo. de 2020
You can change the thick labels with:
h=figure();
plot(1:10)
h.CurrentAxes.YTick=[1,3,6]
In this example ythicks: 1, 3, 6 are shown.

Iniciar sesión para comentar.

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 23 de Mzo. de 2020
Something like this works. Note that you'll have some challenges because most of your y values are very small, so it might not look quite like you'd expect.
p1 = rand([50,1])*5.5-1.1;
p2 = rand([50,1])*3.5e-6 - 3e-6;
p3 = rand([50,1])*0.5e-6 + 3.8e-6;
p4 = rand([50,1])*4.1e-7 - 3e-7;
p5 = rand([50,1])*0.2e-6 - 3.45e-6;
subplot(5,1,1)
plot(p1)
yval = ylim(gca);
set(gca,'YTick',linspace(yval(1),yval(2),5),"YTickLabel",round(linspace(yval(1),yval(2),5)))
subplot(5,1,2)
plot(p2)
yval = ylim(gca);
set(gca,'YTick',linspace(yval(1),yval(2),5),"YTickLabel",round(linspace(yval(1),yval(2),5),6))
subplot(5,1,3)
plot(p3)
yval = ylim(gca);
set(gca,'YTick',linspace(yval(1),yval(2),5),"YTickLabel",round(linspace(yval(1),yval(2),5),6))
subplot(5,1,4)
plot(p4)
yval = ylim(gca);
set(gca,'YTick',linspace(yval(1),yval(2),5),"YTickLabel",round(linspace(yval(1),yval(2),5),7))
subplot(5,1,5)
plot(p5)
yval = ylim(gca);
set(gca,'YTick',linspace(yval(1),yval(2),5),"YTickLabel",round(linspace(yval(1),yval(2),5),6))

Más respuestas (0)

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Productos


Versión

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by