I am making a chart of border entries and exits, and I would like to add an annotation of events (migration policies) to the chart.
I have two dataframes: one of entries and exits (Flows), and another for the events, with dates(policies).
I have managed to plot the entries and exits plus the events (as points) with the following code:
chart7<-ggplot()
geom_line(data=Flow,
aes(x=date,
color=flujo), stat="count")
geom_point(data = policies,
aes(x=dates, y=150000, color=type_events))
geom_vline(data=policies,
aes(xintercept=dates))
scale_x_date(date_minor_breaks = "1 month",
date_labels = "%Y (%b)")
labs(color="Type of Flow")
ggtitle("Number of Exits and Entrances, by Month, 2017-2021")
xlab("Date")
ylab("Number or People")
ggplotly(chart7)
CodePudding user response:
I updated the geom_vline()
with col="yellow", lwd=1, lty=1
(ggplot()
geom_line(data=Flow,
aes(x=date,
color=flujo), stat="count")
geom_point(data = policies,
aes(x=dates, y=150000, color=type_events))
geom_vline(data=policies,
aes(xintercept=dates), col="yellow", lwd=1, lty=1)
scale_x_date(date_minor_breaks = "1 month",
date_labels = "%Y (%b)")
labs(color="Type of Flow")
ggtitle("Number of Exits and Entrances, by Month, 2017-2021")
xlab("Date")
ylab("Number or People"))
theme_bw()