Can not seem to get the max and min point text on Geom_line to shift to a better position

Viewed 21

I am having a hard time figuring out how to move the text on my plot to be more readable. It correctly show the max and min points, but the positioning makes it hard to read. I have tried using vjust in the aes syntax but it does not seem to do anything.

my code is as follows:

ggplot (btcc, aes (x = date, y = adj_close, group = 1)) + 
geom_line (color = "black") + 
geom_point (data = btcc[which.min(btcc$adj_close), ], color = "red") +
geom_point (data = btcc[which.max(btcc$adj_close), ], color = "blue") + 
geom_text (data = rbind(btcc[which.min(btcc$adj_close), ], btcc[which.max(btcc$adj_close), ]),
aes (date+1, adj_close, label = adj_close, vadjust = -1)) +
labs (x = "DATE", y = "ADJUSTED CLOSE", title = "BTCC ADJUSTED CLOSE VS DATE")

below is what I am seeing Chart thank you in advance for your help.

1 Answers

You most likely want to tinker with the nudge_x argument in this case:

geom_text (data = rbind(btcc[which.min(btcc$adj_close),],
                        btcc[which.max(btcc$adj_close),]),
           aes(date+1, adj_close, label = adj_close,),
           hjust = 0,
           nudge_x = 0.05
)
Related