How to plot a time series with multiple y axes
3 views (last 30 days)
Show older comments
Hi!
I would like to plot 3 data sets with different scales over the same time axis. It would look like the image below that was created with a different software. There use see the time on the x-axis, and 3 different y-axes for my pressure, depth and temperature data.
My data is stored in 3 time series:
ts_p = timeseries(p_hydro, time, 'Name', 'Pressure');
ts_T = timeseries(T, time, 'Name', 'Temperature');
ts_sensorDepth = timeseries(sensorDepth, time, 'Name', 'Sensor Depth');
I tried the function plotyyy that I found on File Exchange http://www.mathworks.com/matlabcentral/fileexchange/1017-plotyyy
plotyyy(ts_p.Time, ts_p.Data, ts_T.Time, ts_T.Data, ts_sensorDepth.Time, ts_sensorDepth.Data, {'kPa', 'degC', 'meters'})
But the properties of the x-axis where not the same as those of a simple time series plot, e.g.
plot(ts_p)
In this case, the x-axis can be formated to show a certain time format, e.g.'mm/dd/yy HH:MM:SS', and when you zoom in, the x-axis adjust itself. I would like to have these features in my plot.
Does anybody have an idea?
0 Comments
Answers (1)
Walter Roberson
on 29 Jan 2016
ax3 = plotyyy(ts_p.Time, ts_p.Data, ts_T.Time, ts_T.Data, ts_sensorDepth.Time, ts_sensorDepth.Data, {'kPa', 'degC', 'meters'});
for ax = ax3(:).'
datetickzoom(ax, 'MM/DD/YY');
end
linkaxes(ax3, 'x');
See Also
Categories
Find more on Line Plots 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!