
add text to subplot
6 ビュー (過去 30 日間)
古いコメントを表示
I have a figure with 5 subplots. In each subplot there are various patches which I included using an array of x-values. Is it possible to add a textbox next to/below each patch?
I tried the following, but nothing came up:
ax(1)=subplot(5,1,1)
% code to create subplots
% x_left_value and x_right_value are two arrays with the respective x values
center_value = (x_left_value + x_right_value)/2;
side_value = (center_value - x_left_value)*[-1 1]
x_value = center_value + side_value;
y_value = ylim(ax(1))
patch1 = patch(ax(1), x_value([1 1 2 2]), y_value([1 2 2 1]), 'b','EdgeColor','r','FaceAlpha',0.1)
text(ax(1), x_left_value, x_right_value,'text here');
following is what I want to achieve:

any help thank you!
6 件のコメント
Adam Danz
2020 年 8 月 24 日
What are the values of x_left_value, x_right_value?
By default, text objects have the "clipping" property set to 'off' which means they will appear even if the text extends beyond the axis limits. But if the text extends so far that it goes off the figure, you won't see it. If the text is under an opaque object, you also won't see it.
So, check that your text coordinates are reasonable.
dpb
2020 年 8 月 24 日
Of course it works...you see the figure. As Adam points out, if you don't use reasonable coordinate values or have the focus on the wrong axis or such, you may not have the desired result.
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Discrete Data Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!