add text to subplot

6 vues (au cours des 30 derniers jours)
Djdj Cjcjxj
Djdj Cjcjxj le 24 Août 2020
Commenté : dpb le 24 Août 2020
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 commentaires
Adam Danz
Adam Danz le 24 Août 2020
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
dpb le 24 Août 2020
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.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Discrete Data Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by