How do I show different x-axis up and down
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I'm am plotting the energy as a function of volume for a system and I want to show the volume on the x-axis down and the corresponding sidelength (i.e. the cubic root of the volume) on a similar x-axis top. The problem is that the cubic root produces a long series of decimals and I only want the ticks at the top x-axis in integer values of the side length, which is not equal to integer numbers for the volume. I.e. I don't want the ticks top and down to be at the same positions. So far I've come up with this:
plot(V, E), hold on L = V.^(1/3) axes('YAxisLocation','right','XAxisLocation','top','color','none') set(gca,'XTickLabel',L,'YTickLabel',[])
Any idea on how I might set the 'XTick' property on the top x-axis in such a way that the ticks coinside with integer values of L?
0 comentarios
Respuestas (1)
Star Strider
el 26 de Feb. de 2015
Set the 'XTickLabel' values specifically:
V = logspace(1,3,5); % Create Data
L = V.^(1/3);
xlbl = strsplit(sprintf('%.0f\n', L), '\n');
xlbl = xlbl(1:end-1);
then:
set(gca,'XTickLabel',xlbl,'YTickLabel',[])
2 comentarios
Star Strider
el 26 de Feb. de 2015
I don’t know what ‘E’ is supposed to be, so I got creative.
In that event, define the 'XTick' positions as well, and round the ‘L’ values first:
V = logspace(1,3,5); % Create Data
E = V.^2;
L = V.^(1/3);
RL = round(L);
xlbl = strsplit(sprintf('%.0f\n', RL), '\n');
xlbl = xlbl(1:end-1);
plot(V, E)
set(gca, 'YAxisLocation','right','XAxisLocation','top','color','none')
set(gca,'XTick',RL.^3,'XTickLabel',xlbl,'YTickLabel',[])
You will probably have to experiment to get the result you want.
Ver también
Categorías
Más información sobre Lighting, Transparency, and Shading en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!