Attempting to alter the color used by the legend.
1 回表示 (過去 30 日間)
古いコメントを表示
When I run this code both of the plots use the same colors, is there any way to change it so that mumpsSummer uses a different color scheme?
%% Plot summer mumps cases on the same graph.
figure, hold on
plot(years, measlesSpring./1000)
plot(years, mumpsSummer./1000)
hold off
xlabel('Month')
ylabel('Cases (in thousands)')
title('NYC measles cases for spring: 1931-1941 vs NYC mumps cases for summer')
legend('March','April','May','June','July','August')
0 件のコメント
回答 (1 件)
Ced
2015 年 1 月 21 日
I'm assuming you want to change the color in the plot too, not just the legend? To define a color for a plot, simply use:
plot(years, measlesSpring./1000, 'r')
if you use the standard matlab colors ('r', 'b', 'k', ... check doc plot for a list)
or
plot(years, measlesSpring./1000,'Color',[r g b])
with normalized (between 0 and 1) rgb values for an arbitrary color. This is all described (with examples) in the documentation, just type "doc plot" into your matlab command line.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Line Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!