7 views (last 30 days)

Hi

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
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')

xlim([0,4])

ylim([0,4])

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

Opportunities for recent engineering grads.

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

Start Hunting!
## 19 Comments

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/545588-text-overlapp-in-uifigure-plot#comment_892229

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/545588-text-overlapp-in-uifigure-plot#comment_892229

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/545588-text-overlapp-in-uifigure-plot#comment_892400

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/545588-text-overlapp-in-uifigure-plot#comment_892400

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/545588-text-overlapp-in-uifigure-plot#comment_892427

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/545588-text-overlapp-in-uifigure-plot#comment_892427

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/545588-text-overlapp-in-uifigure-plot#comment_893012

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/545588-text-overlapp-in-uifigure-plot#comment_893012

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/545588-text-overlapp-in-uifigure-plot#comment_893507

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/545588-text-overlapp-in-uifigure-plot#comment_893507

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/545588-text-overlapp-in-uifigure-plot#comment_893627

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/545588-text-overlapp-in-uifigure-plot#comment_893627

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/545588-text-overlapp-in-uifigure-plot#comment_893693

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/545588-text-overlapp-in-uifigure-plot#comment_893693

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/545588-text-overlapp-in-uifigure-plot#comment_893834

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/545588-text-overlapp-in-uifigure-plot#comment_893834

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/545588-text-overlapp-in-uifigure-plot#comment_894035

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/545588-text-overlapp-in-uifigure-plot#comment_894035

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/545588-text-overlapp-in-uifigure-plot#comment_894351

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/545588-text-overlapp-in-uifigure-plot#comment_894351

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/545588-text-overlapp-in-uifigure-plot#comment_894698

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/545588-text-overlapp-in-uifigure-plot#comment_894698

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/545588-text-overlapp-in-uifigure-plot#comment_895188

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/545588-text-overlapp-in-uifigure-plot#comment_895188

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/545588-text-overlapp-in-uifigure-plot#comment_895278

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/545588-text-overlapp-in-uifigure-plot#comment_895278

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/545588-text-overlapp-in-uifigure-plot#comment_895362

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/545588-text-overlapp-in-uifigure-plot#comment_895362

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/545588-text-overlapp-in-uifigure-plot#comment_895371

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/545588-text-overlapp-in-uifigure-plot#comment_895371

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/545588-text-overlapp-in-uifigure-plot#comment_895383

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/545588-text-overlapp-in-uifigure-plot#comment_895383

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/545588-text-overlapp-in-uifigure-plot#comment_895386

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/545588-text-overlapp-in-uifigure-plot#comment_895386

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/545588-text-overlapp-in-uifigure-plot#comment_895401

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/545588-text-overlapp-in-uifigure-plot#comment_895401

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/545588-text-overlapp-in-uifigure-plot#comment_895413

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/545588-text-overlapp-in-uifigure-plot#comment_895413

Sign in to comment.