How to create a uniform y-tick interval in subplots

11 次查看(过去 30 天)
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 个评论
Stijn Haenen
Stijn Haenen 2020-3-23
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.

请先登录,再进行评论。

采纳的回答

Cris LaPierre
Cris LaPierre 2020-3-23
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))

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by