Plotting multi-colored line in Matlab

前端 未结 3 1981
醉酒成梦
醉酒成梦 2020-12-31 06:12

I would like to plot a vertical line (I\'d prefer any orientation, but I\'d be happy with just vertical right now) with two-color dashes, say red-blue-red-blue-...

I

3条回答
  •  一生所求
    2020-12-31 07:15

    I don't know how to do exactly what you want, but presumably the reason you want to do this is to have some way of distinguishing this line from other lines. Along those lines, take a look at MathWorks' documentation on 2-D line plots. Specifically, this example:

    plot(x,y,'--rs','LineWidth',2,...
                    'MarkerEdgeColor','k',...
                    'MarkerFaceColor','g',...
                    'MarkerSize',10)
    

    should give you plenty of ideas for variation. If you really need the two-color dashes, it might help to specify why. That way, even if we can't answer the question, perhaps we can convince you that you don't really need the two-color dashes. Since you've already ruled out the over-lapping solution, I'm fairly certain there's no solution that answers all of your needs. I'm assuming the two-colorness is the most fluid of those needs.

提交回复
热议问题