help with using plotyy
Mostrar comentarios más antiguos
I want to plot four sets of data using plotyy. The four sets are two sets of experimental data and the other two are predicted (calculated) values. Therefore, they would have different sizes. Ex, the experimental data for x and y are 13 points, while for predicted value, I have x=0:100:1. Therefore I can not use the plotyy with matrix method. Could anyone help with this? Thanks in advance.
Respuesta aceptada
Más respuestas (1)
the cyclist
el 31 de Mzo. de 2015
plotyy is really only needed if your different y values have very different scales (e.g. number of employees and total revenue over time). Because you are doing a fit, I am guessing that your y values are about the same scale.
Therefore, I think you really only need the ability to plot two lines on the same plot (even if they different lengths.) There are several ways to accomplish that. Here is one simple example.
% Pretend data with 13 points
data_x = rand(1,13);
data_y = rand(1,13);
% Pretend fit with 100 points [NOT AN ACTUAL FIT. JUST MADE UP!]
fit_x = linspace(0,1);
fit_y = 0.5*ones(size(fit_x)) + 0.1*fit_x.^2;
% Figure with both data and "fit"
figure
hold on
plot(data_x,data_y,'.')
plot(fit_x,fit_y)
3 comentarios
Jingxin
el 31 de Mzo. de 2015
Chad Greene
el 31 de Mzo. de 2015
I agree with the cyclist. If you're comparing predicted values to measured values, you should not use plotyy. If the y scales are so vastly different between predicted and measured values, that's probably an issue worth depicting clearly, letting the viewer directly compare the different values. Use
plot(x,predicted_y,'k-')
hold on
plot(x,measured_y,'ro')
Jingxin
el 2 de Abr. de 2015
Categorías
Más información sobre Two y-axis en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!