Plot lables with hold on
조회 수: 14 (최근 30일)
이전 댓글 표시
plot(R, ':.b') %blue
xlabel('Time')
ylabel('Dollar')
hold all
plot(L, '-.g') %green
plot(D, '--r') %red
I'm using hold all to plot R, D, and L as shown above. How can I show a label for each one with the same color, using 'legend'? Any other suggestion would be appreciated! :)
Thanks,
댓글 수: 0
답변 (1개)
Walter Roberson
2012년 6월 24일
You want the colors in the legend to be all the same as each other ("the same color"), or you want the colors in the legend to correspond to the line colors?
If you want the colors in legend to correspond to the line colors, just call legend() and specify the labels: it will automatically use the line colors that were used in the plotting.
댓글 수: 3
Walter Roberson
2012년 6월 24일
Call legend() after all three plot() commands have been done: it should use the corresponding colors.
For deeper darker details on legend(), see http://www.mathworks.com/help/techdoc/creating_plots/braliom.html
참고 항목
카테고리
Help Center 및 File Exchange에서 Legend에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!