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

2 visualizaciones (últimos 30 días)
JonThe
JonThe el 5 de En. de 2018
Comentada: JonThe el 5 de En. de 2018
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')

Respuestas (1)

Benjamin Kraus
Benjamin Kraus el 5 de En. de 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 comentarios
JonThe
JonThe el 5 de En. de 2018
Editada: JonThe el 5 de En. de 2018
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 el 5 de En. de 2018
I solved the problem by changing computer. The problem was that I was sitting on a remote desktop.

Iniciar sesión para comentar.

Categorías

Más información sobre Axes Appearance en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by