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

1 次查看(过去 30 天)
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 个评论
Jan
Jan 2019-3-14
@Ritabrata Chakraborty: Is this a comment to my answer? Does my answer solve the problem?
Ritabrata Chakraborty
@Jan Yes.. Using 'text' solve my problem. I inserted a value beside axis with 'text', then it was easily adjustable using plot edit options.

请先登录,再进行评论。

采纳的回答

Jan
Jan 2019-3-13
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 个评论
Ritabrata Chakraborty
@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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

标签

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by