Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in R Programming by (7.3k points)
edited by

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

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

Browse Categories

...