ggplot2 - How can I manipulate a ggplot in R to allow extra room on lhs for angle=45 long x-axis labels? -


this question has answer here:

i have several geom_bar ggplots have long names x-axis text. if plot them @ angle=90, takes lot of room @ bottom of graph, trying angle=45. causes left hand side of first label cut off. there way increase left margin?

(not allowed post image example)

ggplot(aes(x = cm, y = ahead_aadt),         data = sbt) +     geom_point( ) + geom_line() +    ggtitle("ahead aadt traffic counts on 101 in s santa barbara cty") +     theme(axis.text.x = element_text(angle=45, size = 9,      color = "black", face = "plain", vjust = 1, hjust = 1),       panel.grid.major.x = element_line(colour = "black", linetype = "dotted")) +   xlab("cumulative mileage") + ylab("ahead aadt") +    scale_x_continuous(breaks = sbt$cm,                       labels =  sbt$description) 

this not best answer, added several "\n\n\n" before y-axis label text made label text wider. moves actual plot , associated labels farther right, giving more room text on left.

ggplot(aes(x = cm, y = ahead_aadt),         data = sbt) +     geom_point( ) + geom_line() +    ggtitle("ahead aadt traffic counts on 101 in s santa barbara cty") +     theme(axis.text.x = element_text(angle=45, size = 9,      color = "black", face = "plain", vjust = 1, hjust = 1),       panel.grid.major.x = element_line(colour = "black", linetype = "dotted")) +   xlab("cumulative mileage") + ylab("\n\n\nahead aadt") +    scale_x_continuous(breaks = sbt$cm,                       labels =  sbt$description) 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -