MATLAB Answers

How do I right or left justify text in my plot?

363 views (last 30 days)
How do I right or left justify text in my plot?
The Handle Graphics property 'HorizontalAlignment' does not right justify the text in my title as I expected. I want my title to appear on the top right-hand side of my figure.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 7 Jul 2020 at 4:00
Edited: MathWorks Support Team on 7 Jul 2020 at 14:18
To justify text in your figure, you will need to change both the HorizontalAlignment and Position properties. These properties are described in more detail at the following URL:
The following code demonstrates one way that you could right justify your title.
plot(1:10)
t = title('hi')
set(t, 'horizontalAlignment', 'right')
set(t, 'units', 'normalized')
h1 = get(t, 'position')
set(t, 'position', [1 h1(2) h1(3)])

  0 Comments

Sign in to comment.

More Answers (0)


Translated by