Borrar filtros
Borrar filtros

Multiple X-Axes with separate scales and xlabels

47 visualizaciones (últimos 30 días)
Nathaniel H Werner
Nathaniel H Werner el 9 de Abr. de 2020
Respondida: Rajani Mishra el 14 de Abr. de 2020
I am trying to make a figure with two x-axes, and I want each axis to have a separate scale because they represent different intervals/variables.
Here is what I have so far.
ax1 = gca; % current axes
ax1.XColor = 'k';
ax1.YColor = 'k';
ax1_pos = ax1.Position; % position of first axes
ax2 = axes('Position',ax1_pos,...
ax2.XColor = 'r';
The default scale for the top (red) axis is 0 1. I can change the tick marks that are shown but I want them to vertically line up with the black tick marks and for this graph go from -1 to 0. I'm just using 0.1 and 0.2 since they seem to line up by eyeballing it.
I also want the there to be an xlabel, but the default location is above the axis since it's on top. How can I move the label so that it's on the same level as tick labels? The only way that I can actually see the label is if I make the figure full screen.
ylabel(ax1,'(y-y_{wing})/\Delta y')
Regular size, you can barely see any of the top xlabel (the arrow is about where I want it to be), but you can see it in fullscreen.
Update: I just figured out I can change the VerticalAlignment to top and this moves the xlabel on top to exactly where I want it. No need to provide an answer for that.

Respuesta aceptada

Rajani Mishra
Rajani Mishra el 14 de Abr. de 2020

Más respuestas (0)




Community Treasure Hunt

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

Start Hunting!

Translated by