Plot time series in selected axes
4 views (last 30 days)
Show older comments
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?
0 Comments
Accepted Answer
Guillaume
on 12 Mar 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 Comments
More Answers (0)
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!