0 votes
1 view
in R Programming by (6.5k points)

My example is:

qplot(mtcars$mpg) + annotate(geom = "text", x = 30, y = 3, label = "Some text\nSome more text")

How do I get the text here to be left-aligned? So that the 'Some's line-up with each other.

1 Answer

0 votes
by (25.3k points)

To left-align text in annotate function, you can use the hjust argument that is used to control the horizontal justification, 0 means left-justified, 0.5 means centered, and 1 means right-justified.

In your case:

qplot(mtcars$mpg) +

  annotate(geom = "text", x = 30, y = 3,

           label = "Some text\nSome more text",

           hjust = 0)

Output:

image

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...