How to add a specific value with arrow or a marker in the axis of a plot?

3 vues (au cours des 30 derniers jours)
I have a 2D plot. I plotted a curve and the average of the data in the same plot. I want to write the average value beside the Y-axis to indicate the average value. How to write it ?
  4 commentaires
Jan
Jan le 14 Mar 2019
@Ritabrata Chakraborty: Is this a comment to my answer? Does my answer solve the problem?
Ritabrata Chakraborty
Ritabrata Chakraborty le 17 Mar 2019
@Jan Yes.. Using 'text' solve my problem. I inserted a value beside axis with 'text', then it was easily adjustable using plot edit options.

Connectez-vous pour commenter.

Réponse acceptée

Jan
Jan le 13 Mar 2019
x = rand(1, 10);
m = mean(x);
axes('XLim', [1, 10], 'NextPlot', 'add', 'Box', 'on');
plot(x, 'b');
yline(m, 'g');
text(10.01, m, 'Mean', ...
'Color', 'g', ...
'HorizontalAlignment', 'left', ...
'Units', 'data');
The creates the text slightly right from the axes.
  1 commentaire
Ritabrata Chakraborty
Ritabrata Chakraborty le 17 Mar 2019
@Jan I think using 'text' to insert the required word, and then edit the positioning and color with edit figure option is easier and faster option.

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by