How can I use pbaspect and MinorTick in subplot with three plots?

2 次查看(过去 30 天)
I'm trying to use three subplots with pbaspect([1 1 1]) and MinorTick. Everything works fine if I exclude pbaspect or only use two subplots but that isn't what I want.
How do I get three horizontal plots with MinorTicks and without stretch-to-fill?
x = [0:1:16];
subplot(1,3,1)
plot(x, 0.5*x)
axis([0 15 0 15])
pbaspect([1 1 1])
grid on
hA=gca;
hA.YAxis.MinorTickValues = [0:1:15];
hA.XAxis.MinorTickValues = [0:1:15];
set(gca,'yMinorTick','on')
set(gca,'xMinorTick','on')
subplot(1,3,2)
plot(x, 1.5*x)
axis([0 15 0 15])
pbaspect([1 1 1])
grid on
hA=gca;
hA.YAxis.MinorTickValues = [0:1:15];
hA.XAxis.MinorTickValues = [0:1:15];
set(gca,'xMinorTick','on','yMinorTick','on')
subplot(1,3,3)
plot(x, 1*x)
axis([0 15 0 15])
pbaspect([1 1 1])
grid on
hA=gca;
hA.YAxis.MinorTickValues = [0:1:15];
hA.XAxis.MinorTickValues = [0:1:15];
set(gca,'xMinorTick','on','yMinorTick','on')

回答(1 个)

Benjamin Kraus
Benjamin Kraus 2018-1-5
What isn't working when you use three plots instead of two?
I just tested your code, and the only thing I noticed is that as the plots get small, the length of the ticks gets really small. You could try increasing the tick length:
x = 0:1:16;
multiplier = [0.5 1.5 1];
n = 3;
for s = 1:n
hA = subplot(1,n,s);
plot(x, multiplier(s)*x)
axis([0 15 0 15])
pbaspect([1 1 1])
grid on
hA.YAxis.MinorTickValues = 0:1:15;
hA.XAxis.MinorTickValues = 0:1:15;
set(hA,'yMinorTick','on')
set(hA,'xMinorTick','on')
hA.TickLength = [0.05 0.05]; % Increasing the tick length
end
  2 个评论
JonThe
JonThe 2018-1-5
编辑:JonThe 2018-1-5
Hi! Thanks for your help! I attached a picture showing how it looks for me. I'm sorry I didn't mentioned that the MinorTick disappears on all axis except one, when I use three instead of two plots. I will try your suggestion.
JonThe
JonThe 2018-1-5
I solved the problem by changing computer. The problem was that I was sitting on a remote desktop.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Axes Appearance 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by