フィルターのクリア

More line objects returned by findobj() than there are lines

1 回表示 (過去 30 日間)
Gunnar
Gunnar 2014 年 8 月 8 日
コメント済み: Azzi Abdelmalek 2014 年 8 月 8 日
Hello!
I am looking to change the legend color and am using the following snippet of code:
x = 0:10;
y1 = 5*x; % Line 1
y2 = 5*x + 5; % Line 2
fig = fig + 1; figure(fig);
plot(x,y1,'k'), hold on
plot(x,y2,'b'), hold on
hleg = legend('Line 1','Line 2')
hlegline = findobj(hleg,'Type','Line')
set(hlegline(2), 'Color', 'g');
set(hlegline(4), 'Color', 'r');
As you can see, I am using objects 2 and 4. My question is, what do objects 1 and 3 represent, i.e. hlegline(1) and hlegline(3), respectively? I haven't been able to detect the difference nor find the answer online.
Thank you for your help!

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 8 月 8 日
Try this to understand
set(hlegline(1),'marker','*')
set(hlegline(1),'marker','o')
set(hlegline(3),'marker','o')
set(hlegline(3),'color','y')
  2 件のコメント
Gunnar
Gunnar 2014 年 8 月 8 日
Thanks, Azzi! :-)
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 8 月 8 日
You can get all the properties of the handle hlegline(3) by
set(hlegline(3))

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpecifying Target for Graphics Output についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by