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

10 views (last 30 days)
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?

Accepted Answer

Voss
Voss on 10 Jun 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')

More Answers (0)

Tags

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by