Setting y-axes range on plot with multiple x- axes
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Andreas Volden
el 15 de Dic. de 2014
Comentada: Andreas Volden
el 16 de Dic. de 2014
Hi! I'm having some issues regarding a plot with two x-axes and a similar y-axis. At least, that's what I want. My code from matlab looks like this:
t1 = [1:length(q_mean_norm)];
t2 = [1:length(q_mean_pc_dt_zero)];
figure(3)
xlabels{1} = 'q_mean_norm valid samples[s]';
xlabels{2} = 'q_mean_pc_dt_zero valid samples[s]';
ylabels{1} = 'Flow [l/min]';
ylabels{2} = 'Flow [l/min]';
[ax,hl1,hl2] = plotxx(t1,q_mean_norm,t2,q_mean_pc_dt_zero,xlabels,ylabels);
grid;
The problem is that my two y-axes in this case are different. The two functions have minor differences which in this case could be neglected. Hence it would be favourable to keep the y-axes limits the same, in this case [-100,2000], regardeless of the fact that the two x-axes don't match.
I've tried different commands to manipulate both y-axes without any luck. Any tips you got? Thanks!
0 comentarios
Respuesta aceptada
dpb
el 15 de Dic. de 2014
Editada: dpb
el 16 de Dic. de 2014
...keep the y-axes limits the same, in this case [-100,2000]...
set(ax,'ylim',[-100 2000])
Alternatively, you can use linkaxes and then manipulate only one and the other will follow...
linkaxes(ax,'y')
ylim(ax(1),[-100 2000])
For some reason I've never fathomed, [x|y]ylim don't accept a vector of handles; you have to use set to do more than one at a time. linkaxes then lets you do just the one and use ylim as demonstrated but it's not a lot of help overall in reducing code as you then have to use the specific axes handle.
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!