Effacer les filtres
Effacer les filtres

plotyy does not what i want...

4 vues (au cours des 30 derniers jours)
Florian
Florian le 19 Juil 2012
Hello there,
I want to plot 2 graphs with different lengths in one figure.
maxidx_smooth2 is a 484x1 vector time_climate_h is a 893x1 vector temp_climate is a 893x1 vector
I tried 'plotyy' but I don´t come along with the 'X' arguments, somehow MATLAB rejects this but for what reason?
% plotyy(time_climate_h,maxidx_smooth2,time_climate_h,temp_climate)
RESULTS IN: "Error using plot Vectors must be the same lengths."
But why? I thouht this is the reason ... plot two different vectors in one plot with different lenghts?
Thanks,

Réponse acceptée

Conrad
Conrad le 19 Juil 2012
Hi Florian
plotyy(x1,y1,x2,y2)
The length of y1 must be the same as x1 and the length of y2 must be the same as x2 but x1 and x2,and hence, y1 and y2 can have different lengths.
See the example below:
% Create dummy data.
x1 = 1:10; x2 = 2:5;
y1 = rand(1,length(x1)); y2 = rand(1,length(x2));
h = plotyy(x1,y1,x2,y2);
Conrad

Plus de réponses (1)

Jan
Jan le 19 Juil 2012
Modifié(e) : Jan le 19 Juil 2012
You could not even draw one of these diagrams using the standard plot.
  • maxidx_smooth2 is a 484x1 vector
  • time_climate_h is a 893x1 vector
==>
plot(time_climate_h, maxidx_smooth2) % ERROR
X and Y data need the same number of elements.

Catégories

En savoir plus sur Two y-axis dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by