我正在制作邊界進入和退出的圖表,我想在圖表中添加事件(遷移策略)的注釋。
我有兩個資料框:一個進入和退出(流),另一個用于事件,帶有日期(政策)。
我設法使用以下代碼繪制了進入和退出以及事件(作為點):
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)
結果如下:
uj5u.com熱心網友回復:
我更新了 geom_vline()與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()

轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/371929.html
