在ggplot中出现多个离群值 -> 将alpha调整为outlier.color

5
我希望将箱线图中的异常点设置为半透明。在这里,他们使用了“抖动”(类似的思路,不同的方法)。
我的代码:
ggplot() + 
geom_boxplot(aes(x = Sistema, y=values, linetype = Sistema), 
             data=estacado, outlier.size=1, outlier.shape=2) + 
coord_flip() + 
labs(x="Sistema", y=expression(paste("RMSD ",(ring(A))))) +
opts(legend.position="none")

我的数据

>head(estacado)
    values   ind Sistema
1 0.310214 r24_a     R24
2 0.428232 r24_a     R24
3 0.460971 r24_a     R24
4 0.482923 r24_a     R24
5 0.492656 r24_a     R24
6 0.515591 r24_a     R24
> tail(estacado)
          values   ind Sistema
4999995 1.723030 g24_e     G24
4999996 1.718444 g24_e     G24
4999997 1.720745 g24_e     G24
4999998 1.737137 g24_e     G24
4999999 1.733106 g24_e     G24
5000000 1.738487 g24_e     G24

http://dl.dropbox.com/u/19202810/Rplot01.png http://dl.dropbox.com/u/19202810/Rplot01.png

在上述链接中,他们修改了函数geom_boxplot; 我希望像 outlier.colour= alpha("black", 1/2) 这样更容易的方法,但这会导致错误:

Error in do.call("layer", list(mapping = mapping, data = data, stat = stat,  : 
  could not find function "alpha"

非常感谢您的帮助。

1个回答

4
ggplot2 版本 0.9.0 起,alpha 函数被移动到(当时的新)scales 包中。要使用它,您需要包含相应的代码。
library("scales")

除了

,还要注意。
library("ggplot2")

在你的脚本中。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接