How to add extra text to plot legend?

246 ビュー (過去 30 日間)
Giuseppe
Giuseppe 2022 年 3 月 11 日
回答済み: Kiran Felix Robert 2022 年 3 月 15 日
Hi, guys
Let us suppose that I have the following simple code:
clc; clear all; close all;
x = linspace(0, 2*pi, 100);
figure
hold on;grid on; box on;
plot(x,sin(x));
plot(x, cos(x));
plot(x, tan(x));
axis([0 2*pi -4 4]);
legend('sin', 'cos', 'tan');
My goal is to add some extra text in the legend box as shown in the following image example (image modified with gimp):
Can you help me to codify this task?
  2 件のコメント
KSSV
KSSV 2022 年 3 月 11 日
You can try legend title.
Giuseppe
Giuseppe 2022 年 3 月 11 日
Thanks! Is it possible to put the title below the legend instead of above?

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

採用された回答

Kiran Felix Robert
Kiran Felix Robert 2022 年 3 月 15 日
Hi Guiseppe,
Please refer the legend properties documentation and the following MATLAB Answer post for legend positioning.

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by