MATLAB Answers

Text overlapp in uifigure plot

7 views (last 30 days)
Jogger on 10 Jun 2020
Commented: Jogger on 28 Aug 2020
I am plotting the text in a ui figure using text(x,y,str). I could not see initial text message as they are over lapping . Can some one help me how can i avoid the overlapping text ?
Thank you!


Adam Danz
Adam Danz on 12 Jun 2020
Ah... good.
Note that you can also do the same thing with
labelpoints(0, 0, 'A', 'E') % For east
labelpoints(0, 0, 'B', 'W') % for west
labelpoints(0, 0, 'C', 'S') % For south
labelpoints(0, 0, 'D', 'N') % For north
% Also NE NW SE SW and C for center
In addition, you can offset the label from the coordinate by using
labelpoints(0, 0, 'D', 'N', 0.1) % where 0.1 is an offset factor
Jogger on 12 Jun 2020
Some how- I don't see accept answer option!
Adam Danz
Adam Danz on 12 Jun 2020
That's because this discussion has been in the comments section. I just added an answer that summarizes the solution.

Sign in to comment.

Accepted Answer

Adam Danz
Adam Danz on 12 Jun 2020
Here are two ways to control the position of text in a plot
Use Matlab's text() function
The HorizontalAlignment and VerticalAlignment properties control the text position relative to the coordinate.
fig = figure();
ax = axes(fig);
textSamples = {'First Row', 'Second Row', 'Third Row'};
x = 1:3
y = 1:3;
plot(ax, x, y, 'bo')
hold(ax, 'on')
% Example of text()
text(ax, x+.05, y, textSamples,'HorizontalAlignment', 'Center', 'VerticalAlignment', 'Bottom')
Use labelpoints() from the file exchange
The same example above can be done with this line below. The 'N' input specifies that the text should be North of the coordinates.
labelpoints(x,y,textSamples,'N','color','b') % N is for North


Jogger on 19 Jul 2020
Hi Adam,
Can you please help with below link issue
You suggestion and guidance would be a great help for me ! Thank you!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!