Given then the following dataframe and plot:
year = c(2007, 2008, 2009, 2010, 2011, 2012)
pc = c(-.17, .0115, -.049, -.0116, -0.059, -.155)
df_test = data.frame(year, pc)
df_test %>%
ggplot(aes(x=year, y=pc, label=pc)) +
geom_line() +
geom_text()
You can see that the labels interfere with the plot. I've tried to manually adjust the labels using geom_text(hjust=0, vjust=-1, size=3)
but this takes a while to get it right.
Is there a way to have the plot labels automatically position themselves above/below or left/right (or alternating above/below left/right)?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.