Adding a label with text on a plot

5 views (last 30 days)
HC98
HC98 on 28 Feb 2024
Answered: Chunru on 28 Feb 2024
I have a plot of some data and I want to highlight one of its distinct peaks like this:
Is there any way that I can do this?

Accepted Answer

Chunru
Chunru on 28 Feb 2024
x = -3:.1:3
x = 1x61
-3.0000 -2.9000 -2.8000 -2.7000 -2.6000 -2.5000 -2.4000 -2.3000 -2.2000 -2.1000 -2.0000 -1.9000 -1.8000 -1.7000 -1.6000 -1.5000 -1.4000 -1.3000 -1.2000 -1.1000 -1.0000 -0.9000 -0.8000 -0.7000 -0.6000 -0.5000 -0.4000 -0.3000 -0.2000 -0.1000
y = exp(-(x-0.5).^2/2);
plot(x, y)
% need to adjust the coordinates (normalized unit)
% doc annotation for more details
annotation("doublearrow", [0.58 0.58], [0.12 0.93]);
text(0.5, 0.4, "a", "Color", "r") % data unit

More Answers (0)

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!