Plot time series in selected axes

4 visualizaciones (últimos 30 días)
PaoloB
PaoloB el 12 de Mzo. de 2015
Comentada: Star Strider el 12 de Mzo. de 2015
How can I plot a time series in an axes, for which I know the handle, rather than in the currently active axes?
For standard plots, if myTargetAxes is the handle to the axes, I can do:
plot(myTargetAxes, 1:200, tan((1:200)./12));
But this does not work with a time series because I can do
plot (myTimeseries)
but if I attempt to do
plot(myTargetAxes, myTimeseries)
I get the error: "A numeric or double convertible argument is expected."
I have found the workaround of calling
axes(myTargetAxes)
before
plot(myTimeseries)
but this seems very ugly. Is there a better way to do it?

Respuesta aceptada

Guillaume
Guillaume el 12 de Mzo. de 2015
plot for timeseries is actually a different function than the general plot. It's a member function of the timeseries class.
I just went through the code of the plot function ( edit timeseries.plot), and the way to specify the axes is with:
plot(myTimeseries, 'Parent', myTargetAxes);
It's kind of alluded to in the documentation where it says that Name, Value is used to specify the Chart Line properties. One of the chart line properties is indeed the parent axis. It certainly could be a bit more explicit.
  2 comentarios
PaoloB
PaoloB el 12 de Mzo. de 2015
Hi Guillaume, thank you very much, it worked.
Star Strider
Star Strider el 12 de Mzo. de 2015
Great work, Guillaume!
+1

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Annotations en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by