how to plot os many curves in one figure with distinct marker?

2 ビュー (過去 30 日間)
Steven
Steven 2013 年 12 月 31 日
コメント済み: Walter Roberson 2013 年 12 月 31 日
I want to draw many plots (say 30) in one figure with distinct color and maker. How can I ask MATLAB to do it automatically?
If I use a loop, it gives all the plots the same color and type.
So I have to use something like this which is too long:
plot(x1,y1,x2,y2,.....x30,y30)
Is there a better way?
Also how can I set the legend for them? Again I have to use such long command for legend:
legend("Plot1','Plot2',....)
Any better way?
Thanks!
Steven

採用された回答

Walter Roberson
Walter Roberson 2013 年 12 月 31 日
You may wish to have a look at the FEX contribution "plt".
Otherwise have a more detailed look at "hold all" and the axes properties ColorOrder and LineStyleOrder.
Remember that you can feed legend() a cell array of strings. Alternately you can feed legend the handle for a graphics object and the legend string to associate with it. See also http://www.mathworks.com/help/matlab/creating_plots/controlling-legends.html
  2 件のコメント
Steven
Steven 2013 年 12 月 31 日
Thanks!
But the "plot" plots all the curves by default as lines.
How can I ask it to draw the plots as distinct markers automatically?
Thanks!
Walter Roberson
Walter Roberson 2013 年 12 月 31 日
set the axis LineStyleOrder to only consist of markers. http://www.mathworks.com/help/matlab/ref/axes_props.html
An example given in that documentation is
set(gca,'LineStyleOrder',{'-*',':','o'})
The third of those LineStyleOrder entries is 'o' which is marker only. You can use any of the markers shown at http://www.mathworks.com/help/matlab/ref/linespec.html

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLegend についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by