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

2 ビュー (過去 30 日間)
JonThe
JonThe 2018 年 1 月 5 日
コメント済み: JonThe 2018 年 1 月 5 日
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 Center および File ExchangeAxes Appearance についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by