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!