How to create a uniform y-tick interval in subplots
15 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Richard Rees
am 23 Mär. 2020
Kommentiert: Richard Rees
am 24 Mär. 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 Kommentar
Stijn Haenen
am 23 Mär. 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.
Akzeptierte Antwort
Cris LaPierre
am 23 Mär. 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))
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Line Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!