How to plot multiple lines with different markers

后端 未结 6 1655
感情败类
感情败类 2021-02-03 12:27

I would like to plot multiple lines with MATLAB and do it so, that markers would be different in every line. I know that with colours this would be achieved with ColorSet

6条回答
  •  清歌不尽
    2021-02-03 13:14

    The easiest way, assuming you are using plot, is to add the type of line in the command. Some of the possible options are: --,:,-,-.. There also options for the marker type and for the width.

    For example this code will generate several lines with different types of markers:

    x = -pi:.1:pi;
    y = sin(x);
    z = cos(x);
    t = tan(x);
    l = x.^2;
    figure();
    hold on;
    plot (x,y,'--g');
    plot (x,z,'-.y');
    plot (x,t,'-b');
    plot (x,l,':r');
    hold off;
    

    the generated graph is: The yellow line is hard to spot, but it's there

    for more help go to: http://www.mathworks.com/help/techdoc/ref/linespec.html

提交回复
热议问题