Attempting to alter the color used by the legend.
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Ced
il 21 Gen 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 Commenti
Vedere anche
Categorie
Scopri di più su Line Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!