How can I use pbaspect and MinorTick in subplot with three plots?
2 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Benjamin Kraus
on 5 Jan 2018
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 Comments
See Also
Categories
Find more on Axes Appearance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!