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에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!