Can legend marker symbols be hard coded in MATLAB?

I am creating simple 2-D line plots with diamonds as the marker symbols. When I add the legend to the plot, the result is as follows;
Is there a way to change the marker symbol in the legend without changing it in the plot?

 採用された回答

Amos
Amos 2015 年 1 月 9 日

0 投票

You can add a second curve that is outside the plot range and denote the symbold that you would like to see in your legend to this second curve. Then you make a legend and assign the text formally to the second curve.
Example:
figure
x_data = 1:10;
y_data = 700*rand(1,10);
plt1=plot(x_data,y_data,'r-d')
hold on
plt2=plot(-100,-100,'*')
set(gca,'Xlim',[1,10],'Ylim',[0,800])
legend(plt2,{'data1'})

1 件のコメント

Brad
Brad 2015 年 1 月 12 日
Amos, cool idea. thanks.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

製品

質問済み:

2015 年 1 月 9 日

コメント済み:

2015 年 1 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by