Plotting different line colors within subplots avoiding duplicate colors?

27 ビュー (過去 30 日間)
Conal Doyle
Conal Doyle 2013 年 6 月 28 日
subplot(2,2,3)
plot(Volume_Major,'LineWidth',2,'color',C);
title ('Evolution of Volume week by week');
xlabel('Time');
ylabel('Volume');
set(gca,'XTick',XTicks);
set(gca,'XTickLabel',XLabels);
legend('EURUSD','EURGBP','EURJPY','USDJPY','GBPUSD','USDCHF','USDCAD','AUDUSD','NZDUSD')
where C is a predefined set {[0 0 1],[1 0.4 0.6],[0 1 1],[1 0 0],[0 1 0],[1 0 1],[0 0.5 0],[0.5 0.5 0.5],[0.7 0.3 0],[1 1 0]}
and Volume_Major is a matrix.
When I plot this I find that an error occurs in the plot. When I change the plot function to plot(Volume_Major,'LineWidth',2), it plots perfectly but colors are duplicated. How do I avoid this?

採用された回答

Tom
Tom 2013 年 6 月 28 日
h = plot(Volume_Major,'LineWidth',2)
set(h,{'Color'},C')

その他の回答 (2 件)

Walter Roberson
Walter Roberson 2013 年 6 月 28 日
h = plot(Volume_Major,'LineWidth',2);
for K = 1 : length(h)
set(h(K), 'LineColor', C(K,:));
end

Tom
Tom 2013 年 6 月 28 日
Or:
set(gca,'NextPlot','ReplaceChildren','ColorOrder',cell2mat(C'))
plot(Volume_Major,'LineWidth',2)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by