[英]How to change in legend text labels using ggplot?
我想更改由紅色和藍色點表示的值的標簽。
#Number and names of variables
[1] "Date" "AOD_500nm"
"Fine_Mode_AOD_500nm.tau_f." "Coarse_Mode_AOD_500nm.tau_c."
#create the plot
ggplot(data4, aes(x = AOD_500nm)) +
geom_point(aes(y = Fine_Mode_AOD_500nm.tau_f., colour =
"Fine_Mode_AOD_500nm.tau_f.")) +
geom_point(aes(y = Coarse_Mode_AOD_500nm.tau_c., colour =
"Coarse_Mode_AOD_500nm.tau_c.")) +
labs(x = "AERONET AOD (500nm)", y = "SDA AOD (500nm)", colour = "Mode" ) +
scale_colour_manual(values = c("red", "blue")) +
scale_fill_discrete(labels = c("Coarse", "Fine")) +
theme(legend.position=c(0.9, 0.9)) +
theme(axis.text.x=element_text(size = 10,hjust=1)) +
theme(axis.text.y=element_text(size = 10)) +
theme(axis.title.x = element_text(size = 12)) +
theme(axis.title.y = element_text(size = 12))
您可以單獨在scale_colour_manual
添加標簽,而不必單獨進行scale_fill_discrete
調用,如下所示:
scale_colour_manual(values = c("red", "blue"), labels = c("Coarse", "Fine"))
這是因為您要對點分別進行colour
,而不是更改fill
值。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.