两行图例标题
Legend Titles with two Lines
我有一个基于不同数据库的包含两条线的图表。第一行有颜色,第二行没有任何颜色。出于某种原因,我无法为第二行(没有颜色的行)添加图例标题。我已经尝试过使用 labs(fill) 和 labs (shape)。有什么线索吗?
我正在为图表使用以下代码:
ggplot()+
geom_line(data=Flow %>%
filter((motivo=="Tourism"|motivo=="Transit") & flujo=="Exits"))
aes(x=date, color=destino_procedencia, text = paste(
"People:", ..count..,
"<br>Date: ", format(as.Date(..x.., origin = "1970-01-01"), "%Y (%b)"),
"<br>Type of Flow: ", ..color..
)), stat="count")+
geom_line(data=Net_migration,
aes(x=date,
y=Saldo, text = paste(
"People:", ..y..,
"<br>Date: ", format(as.Date(..x.., origin = "1970-01-01"), "%Y (%b)")
)))+
labs(color="Country of Destination", fill="Net Migration")+
ggtitle("Number of Exits and Net Migration Rates, by Month and Destination, Venezuelan Nationals,Colombia, 2017-2021")+
xlab("Date")+
ylab("Number or People")
ggplotly(tooltip = c("text"))
您是否尝试过用您想要的值手动填充美学颜色?
参见 Wickham 的书第 11.7 节 ggplot2: elegant graphics for data analysis。顺便说一句,这本书很棒!
我有一个基于不同数据库的包含两条线的图表。第一行有颜色,第二行没有任何颜色。出于某种原因,我无法为第二行(没有颜色的行)添加图例标题。我已经尝试过使用 labs(fill) 和 labs (shape)。有什么线索吗?
我正在为图表使用以下代码:
ggplot()+
geom_line(data=Flow %>%
filter((motivo=="Tourism"|motivo=="Transit") & flujo=="Exits"))
aes(x=date, color=destino_procedencia, text = paste(
"People:", ..count..,
"<br>Date: ", format(as.Date(..x.., origin = "1970-01-01"), "%Y (%b)"),
"<br>Type of Flow: ", ..color..
)), stat="count")+
geom_line(data=Net_migration,
aes(x=date,
y=Saldo, text = paste(
"People:", ..y..,
"<br>Date: ", format(as.Date(..x.., origin = "1970-01-01"), "%Y (%b)")
)))+
labs(color="Country of Destination", fill="Net Migration")+
ggtitle("Number of Exits and Net Migration Rates, by Month and Destination, Venezuelan Nationals,Colombia, 2017-2021")+
xlab("Date")+
ylab("Number or People")
ggplotly(tooltip = c("text"))
您是否尝试过用您想要的值手动填充美学颜色?
参见 Wickham 的书第 11.7 节 ggplot2: elegant graphics for data analysis。顺便说一句,这本书很棒!