我添加了guides(fill = guide_legend)
,但传说中没有显示
在旁边,我想在右上方添加它,那我该怎么办?
我的代码:
Month <- month.abb
Value <- c(20821,28062,20481,22013,22045,19586,23377,27317,20488,23492,20629,23990)
Percentage <- c(0.5314,0.7018,0.5878,0.6463,0.6493,0.6150,0.6530,0.7214,0.6208,0.6421,0.6467,0.6522)
df <- data.frame(Month,Value,Percentage)
df$Month <- factor(df$Month, levels = Month)
library(ggplot2)
library(scales)
p3 <- ggplot(df,aes(x = Month))+ geom_line(aes(y=Value,group=1),color ="#68382C" ,size =1.5)
p3 <- p3 + geom_line(aes(y=Percentage*39000,group=1),color = "#00A4E6",size =1.5)
p3 <- p3 + scale_y_continuous(sec.axis = sec_axis(~./35000,name = "Percentage",labels = scales::percent_format()))
p3 <- p3 + labs(x=NULL)
p3 <- p3 + guides(fill = guide_legend)