Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plotting time series with different colors

Tags:

plot

matlab

I want to plot some time series data where each data point has a label.

So lets say my time series has 365 points. I want to plot these 365 point with their respective colors. They are not spatial points. So I can just have a line where the segments of the line can have different color.

like image 601
user34790 Avatar asked Mar 23 '23 11:03

user34790


1 Answers

check out 3D colored line plot and\or Colored line or scatter plot both from the file exchange.

or if you want to do it yourself you can use surface :

x=linspace(-10,10,256);
y=sin(x);
c=1:numel(x);
colormap(jet(256)); % or whatever colormap you want
surface('XData',  [x(:) x(:)],'YData',[y(:) y(:)],...
        'ZData',0*[x(:) x(:)],'CData',[c(:) c(:)],'EdgeColor','flat');

enter image description here

You can read more on surface properties here.

like image 159
bla Avatar answered Mar 31 '23 15:03

bla