有没有一种方法,以消除在GGPLOT2传说的边界?
-
20-09-2019 - |
题
我使用qplot绘制的函数,我想以定位情节内的图例。我用
opts( legend.position = c(0.7,0.7) )
,以移动其中I希望它是图例
然而有图例周围白色边界和上显示出灰色背景。
例如:
library(ggplot2)
x = c(1:20)
y = c(1:20)
p <- qplot(x,y, color = "blue")
p <- p + scale_colour_identity("Example", breaks=c("blue"), labels=c("dots"))
p <- p + opts(legend.position = c(0.6, 0.4))
print(p)
我想知道如何从图例中删除这条边界。谢谢你。
解决方案
有关ggplot
的较新版本,opts
由theme
&theme_rect
替换被替换element_rect
p + theme(legend.background = element_rect(color = NA))
这将摆脱边框的:
p + opts(legend.background = theme_rect(col = 0))
除了山口(其适用于边界)的其他选项是填充(背景)和尺寸(其是边界大小)。
希望帮助!
所有最好的,
杰
不隶属于 StackOverflow