Code covered by the BSD License  

Highlights from
Shaded time series

5.0

5.0 | 1 rating Rate this file 27 Downloads (last 30 days) File Size: 2.88 KB File ID: #20625
image thumbnail

Shaded time series

by

 

09 Jul 2008 (Updated )

Plot time series one above the other with coloured strips highlighting interesting features.

| Watch this File

File Information
Description

Use this function to plot several time series aligned beneath each other with shaded blocks highlighting important sections.

Acknowledgements

Shade Plot For Emphasis inspired this file.

MATLAB release MATLAB 7.10 (R2010a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (7)
17 Jul 2012 Carl Fischer

Hi Joe,

It sounds like you want multiple lines on a single plot instead of several subplots. There are many variations like this and I don't know how to deal with them without adding loads of parameters or creating several new functions.

I think you can work around it as follows. Run shadedTimeSeries(x,y1,indicator) first. This will give you a single plot with the coloured bars. Then 'hold all'. Then plot(x,y2); plot(x,y3)... This will overlay your other plots on top. Unfortunately, the height of the bars is based on the values of y1, so you have to make sure that y1 goes above and below the other variables.

Feel free to tweak the script for your own purposes. I think you just need to call the internal plot_partial() function with multiple columns in ydata.

-- Carl

17 Jul 2012 Joerg Vetter

Hi Carl,
thanks a lot for this script and the examples. It's totally what I needed.

But how could I manage to put shade in a plot which contains several different lines of data.

Example: One contains the data:
plot(vec1);
hold on;
plot(vec_2);
-->now I'd like to use your shadedTimeSeries function within this single plot

Is this possible?
cheers Joe

07 Sep 2010 Carl Fischer

I uploaded a new version which allows you run this function with only one column of data to populate your own subplots (instead of creating a new figure). Not sure if that's what Kuo-Hsien was requesting. See the examples in the documentation to see how this works.

22 Jun 2010 Carl Fischer

Thanks for the feedback. Not sure what you mean about subplots.
If you just want to display the part of the legend that shows the shaded colour then you can add legend('Interesting bit'); after this function. I feel that anything more sophisticated will be difficult to generalise and may be quite specific to your particular problem. It might be easier if you tweak the function yourself.

21 Jun 2010 Kuo-Hsien

Hi Carl, this is a useful function. How to show the box for subplots and legend? thx.

23 Sep 2009 Carl Fischer

Thanks for the suggestion Shlomi. I've submitted an update but I also added some extra sanity checks to ensure sizes are consistent.

22 Jul 2009 Shlomi

if the indicator is a row vector the function doesn't work properly. I added the simple command of indicator = indicator(:); in my code. You should add it too

Updates
23 Sep 2009

Allow data in rows or columns. Extra sanity checks on data lengths.

23 Sep 2009

Fixed bug that occurred when X was a row vector.

15 Jul 2010

Detect inconsistent data lengths.

06 Sep 2010

Accept different indicators to shade each subplot differently.
If the user specifies a single column of data then use the current plot instead of creating a new one to allow the user more control (eg. custom subplots).

08 Mar 2011

Slight improvement to parameter consistency checks.

Contact us