geom_vline(xintercept = ) - Question

Hi there,

I am trying to draw a vertical line on my X-axis but it does not take that. Can you please help me with this?
Thanks

Francesco

Here is the code:

map(2016:2020, ~ make_returns(Data_m2, .x)) %>%
do.call('rbind', .) %>%
ggplot(aes(x = year_month, y = mean, colour = tercile)) +
geom_line(aes(linetype=tercile))+
scale_color_manual(name = "tercile", values = c("red", "blue"), labels = c("high CSR portfolio", "low CSR portfolio")) +
scale_linetype_manual(name = "tercile", values = c("dashed", "solid"), labels = c("high CSR portfolio", "low CSR portfolio")) +
labs(x = "year", y = "market returns (%)", title = "Portfolios' returns using Sustainalytics ESG total score", font.main=4, font.lab=4) +
scale_x_date(breaks = as.Date(c("2016-01-31", "2017-01-31", "2018-01-31","2019-01-31", "2020-01-31", "2020-12-31")), date_labels = "%Y (%b)") +
geom_vline(xintercept = 2017-01-31, linetype = 2)

Try using a date value for the xintercept.

geom_vline(xintercept = as.Date("2017-01-31"), linetype = 2)

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.