我尝试绘制以下数据:
MONTH;MEDIAN;MIN;MAX
1;-736.12;-5272.96;5946.79
2;3340.83;284.72;15707.46
3;7144.85;2916.79;17659.6
4;9927.73;1660.99;19191.29
5;10986.7;3689.15;16474.34
6;1526.48;-8086.48;13430.86
7;-4415.36;-9244.11;27554.34
8;-3213.32;-8970.76;22089.98
9;-3435.17;-5293.95;12451.59
10;-5112.405;-7002.67;5237.85
11;-7820.8;-11170.12;1164
12;-6143.055;-10836.93;165.82
使用以下代码:
png("amazon_ghm.png", width = 600, height = 400)
ggplot(amazon_ghm) +
geom_line(aes(MONTH, MEDIAN, colour = 'Median'), group=1, size = 2) +
geom_ribbon(aes(MONTH, ymax = MAX, ymin = MIN, fill = "Min/Max"), alpha = 0.5) +
geom_hline(aes(yintercept = 0), linetype="dotted") +
geom_text(size=8, aes(6, 28000, label = "U. Amazon, GHM"))+
theme_bw() +
theme(axis.text=element_text(size=20),
axis.title=element_text(size=20),
axis.line = element_line(colour = "black"),
legend.key = element_rect(fill = "white"),
legend.position = c(.9, .8)) +
labs(x = "Month",
y = "Diff in runoff [m3/s]")+
scale_x_continuous("Month", breaks = 0:12, expand = c(0,0.5)) +
scale_y_continuous(limits = c(-15000, 30000)) +
scale_colour_manual(values = c('Median' ='red4'), name = '')+
scale_fill_manual(values = c('Min/Max' = 'tomato1'), name = '')
不幸的是,当我看到图例项目时,周围会有一些灰色的盒子。我尝试了legend.key = element_rect(fill = "white")
命令,但没有成功。
有谁知道如何摆脱图例项目周围的灰色框?