How can I choose which plots of data to label in a legend for the figure with plots of multiple data sets in MATLAB 7.0 (R14)?

6 ビュー (過去 30 日間)
I am plotting a cosine wave, a sine wave and an amplified sine wave (in that order) on a single plot (figure window). However, I would like my legend to name and display only the cosine wave and the amplified sine wave. The figure itself should display all the plots i.e. cosine, sine, amplified sine.

採用された回答

MathWorks Support Team
MathWorks Support Team 2012 年 5 月 4 日
To show only certain graphics in a legend, explicitly place their handles at the beginning of the call to legend, e.g:
x = -pi:pi/20:pi;
h1 = plot(x,cos(x),'-ro');
hold on
h2 = plot(x,sin(x),'-.b');
h3 = plot(x,2*sin(x),'-*k');
legend([h1 h3],'cos(x)','2*sin(x)')

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeVisualization and Data Export についてさらに検索

タグ

タグが未入力です。

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by