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')
0 件のコメント
回答 (1 件)
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
参考
カテゴリ
Help Center および File Exchange で Axes Appearance についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
