Attempting to alter the color used by the legend.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Ced
am 21 Jan. 2015
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 Kommentare
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!