How to set clipping of text in graph from all sides, so it stays in requested area

8 vues (au cours des 30 derniers jours)
I'm doing a plot/graph in matlab and I need to have also some text in that plot (for some reasons), but when I write this:
app.sometext = text(app.myplot,x_coordinate,y_coordinate, "some long text");
set(app.sometext, 'Clipping', 'on');
... problem is when text is too long. Clipping is set 'on' only from left side but I need to set clipping 'on' from all sides. Does anyone know what to do to set clipping of text in plot from all sides so it stays in requested area?

Réponse acceptée

Voss
Voss le 10 Juin 2022
You can achieve partial text clipping by setting the 'ClippingStyle' property of the axes to 'rectangle':
xy = [0.95, 0.8];
plot(xy(1),xy(2),'ro','LineWidth',2)
hold on
text(xy(1),xy(2),'Text Label','Clipping','on')
xlim([0,1])
set(gca(),'ClippingStyle','rectangle')

Plus de réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Tags

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by