Modifying legend entries in a figure

11 ビュー (過去 30 日間)
Maurilio Matracia
Maurilio Matracia 2020 年 12 月 14 日
コメント済み: Brian Kyanjo 2023 年 9 月 22 日
Dear all,
I am wondering if it is possible to:
1. change the order of the curves in the legend after they have been plotted.
2. Indicate only the characteristics of a group of curves. For example, if I have 4 curves with different colors but two of them have circles and two of them have squares, I want a legend which only shows the circle to group the first 2 curves and the square to group the others.
Thank you in advance for your help! :)
  1 件のコメント
KALYAN ACHARJYA
KALYAN ACHARJYA 2020 年 12 月 14 日
"change the order of the curves in the legend after they have been plotted"
The MATLAB code works sequentially. It is better to understand the requirements, then plot the curves according to the requirements.

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

回答 (1 件)

Hiro Yoshino
Hiro Yoshino 2020 年 12 月 14 日
(1) Imagine that you've got 3 plots:
yourplots = get(gca, 'children');
legend(yourplots([3 1 2]), {'3', '1', '2'});
you can specify the legend as above.
(2) how about using "hggroup" - you can group up some lines and provide the similar attributes
  1 件のコメント
Brian Kyanjo
Brian Kyanjo 2023 年 9 月 22 日
This works for me like magic

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

カテゴリ

Help Center および File ExchangeLegend についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by