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?

回答(1 个)

Walter Roberson
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');
  1 个评论
Julian
Julian 2016-2-2
Thanks! That almost did the job, but not quiet. The x-axis is a bit chaotic as you can see in the screenshot. My time data run from June 23. to Dec. 8. and all time vectors are equal, i.e.
ts_p.Time = ts_T.Time = ts_sensorDepth.Time

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by