フィルターのクリア

Assigning different color in legend

3 ビュー (過去 30 日間)
Mr. 206
Mr. 206 2018 年 9 月 14 日
編集済み: Stephen23 2018 年 9 月 14 日
I am using this code, but it's plotting same color for all the graphs. How can i assign different color for all of them. There is kind of 13/14 graph in one plot.
plot(xz,ys),hold on
%subplot(1,2,2)
%plot(x_0,y_0_diff,'o','markersize',7,xz,ys_diff)
xlabel('1000/T [1/K]')
ylabel('Ignition delay time (ms)')
h=legend("Experiment","M1","M2","M3","M4","M5","M6","M7","M8","M9","M10","M11","M12","location", "northwest");
set (h, "fontsize", 7.9);
  2 件のコメント
madhan ravi
madhan ravi 2018 年 9 月 14 日
Can you upload the data?
Stephen23
Stephen23 2018 年 9 月 14 日
@Atta: what MATLAB version are you using?

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

回答 (2 件)

Pieter Hamming
Pieter Hamming 2018 年 9 月 14 日
The 'r' in plot(xz,ys,'r') means 'red', telling MATLAB you want this line to be plotted in red. If you instead use plot(xz,ys) MATLAB will automatically assign a color.
  2 件のコメント
Mr. 206
Mr. 206 2018 年 9 月 14 日
if i remove that it is plotting by default blue color(all the graphs)
Pieter Hamming
Pieter Hamming 2018 年 9 月 14 日
Can you try the following snippet and tell us what comes out?
ax=gca;
ax.ColorOrder

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


Stephen23
Stephen23 2018 年 9 月 14 日
編集済み: Stephen23 2018 年 9 月 14 日
"How can i assign different color for all of them"
Each time you call plot is independent from the other calls, and so each time the colors start from the first color again. If you want to automatically cycle through the axes ColorOrder colors, then you should do any one of these:
  • set the axes NextPlot property to 'add'.
  • use hold on (only since MATLAB R2014b).
  • use just one plot call.
Then you will get an automatic cycling of the line colors, from the axes ColorOrder:

カテゴリ

Help Center および File ExchangeGraphics Object Properties についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by