Clear Filters
Clear Filters

How to add extra text to plot legend?

205 views (last 30 days)
Hi, guys
Let us suppose that I have the following simple code:
clc; clear all; close all;
x = linspace(0, 2*pi, 100);
hold on;grid on; box on;
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?
KSSV on 11 Mar 2022
You can try legend title.
Giuseppe on 11 Mar 2022
Thanks! Is it possible to put the title below the legend instead of above?

Sign in to comment.

Accepted Answer

Kiran Felix Robert
Kiran Felix Robert on 15 Mar 2022
Hi Guiseppe,
Please refer the legend properties documentation and the following MATLAB Answer post for legend positioning.

More Answers (0)




Community Treasure Hunt

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

Start Hunting!