当前位置: 动力学知识库 > 问答 > 编程问答 >

matlab - Plotting time series with different colors

问题描述:

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.

网友答案:

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');

You can read more on surface properties here.

分享给朋友:
您可能感兴趣的文章:
随机阅读: