How to plot a time series with multiple y axes
8 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Walter Roberson
2016-1-29
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');
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!