我有以下数据集:
structure(list(com = c("v", "v", "v", "v", "v", "v", "v", "v",
"v", "v", "v", "v", "v", "v", "v", "v", "v", "v", "v", "v", "v",
"v", "v", "v", "t", "t", "t", "t", "t", "t", "t", "t", "t", "t",
"t", "t", "t", "t", "t", "t", "t", "t", "v", "v", "v", "v", "v",
"v", "t", "t", "t", "t", "t", "t", "t", "t", "t", "t", "t", "t"
), d = c(0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85,
0.85, 0.85, 0.85, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1.1, 1.1, 1.1, 1.1, 1.1, 1.1, 1.2,
1.2, 1.2, 1.2, 1.2, 1.2, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4,
1.4, 1.4, 1.4, 1.4), strf = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0.25, 0, 0.5, 0, 0, 0, 0.25, 0, 1, 0, 0, 0, 0.5, 1, 1, 1.5,
0.25, 1, 1, 1.5, 1.5, 2, 0.5, 1, 3, 2.5, 2.5, 2, 0, 0.5, 0.25,
0.5, 0.5, 1, 0, 0.5, 1.5, 2, 1, 2.75, 0, 0.5, 0, 0.5, 1.5, 2,
2.5, 3), side = c(2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2,
4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4,
2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2,
4, 2, 4), auf = c("h", "h", "h", "h", "h", "h", "l", "l", "l",
"l", "l", "l", "h", "h", "h", "h", "h", "h", "l", "l", "l", "l",
"l", "l", "h", "h", "h", "h", "h", "h", "l", "l", "l", "l", "l",
"l", "h", "h", "h", "h", "h", "h", "h", "h", "h", "h", "h", "h",
"h", "h", "h", "h", "h", "h", "l", "l", "l", "l", "l", "l"),
zud = c(10.8823529411765, 10.8823529411765, 8.52941176470588,
8.52941176470588, 5, 5, 5, 5, 8.52941176470588, 8.52941176470588,
10.8823529411765, 10.8823529411765, 9.25, 9.25, 7.25, 7.25,
4.25, 4.25, 4.25, 4.25, 7.25, 7.25, 9.25, 9.25, 9.25, 9.25,
7.25, 7.25, 4.25, 4.25, 4.25, 4.25, 7.25, 7.25, 9.25, 9.25,
8.40909090909091, 8.40909090909091, 6.59090909090909, 6.59090909090909,
3.86363636363636, 3.86363636363636, 7.70833333333333, 7.70833333333333,
6.04166666666667, 6.04166666666667, 3.54166666666667, 3.54166666666667,
6.60714285714286, 6.60714285714286, 5.17857142857143, 5.17857142857143,
3.03571428571429, 3.03571428571429, 3.03571428571429, 3.03571428571429,
5.17857142857143, 5.17857142857143, 6.60714285714286, 6.60714285714286
), dru = c(420, 540, 420, 370, 280, 170, 410, 250, 440, 580,
710, 530, 360, 300, 270, 240, 190, 190, 290, 270, 380, 330,
450, 480, 320, 320, 285, 285, 190, 190, 290, 290, 420, 420,
450, 450, 310, 300, 270, 230, 210, 210, 345, 305, 250, 270,
205, 205, 290, 310, 270, 280, 270, 260, 340, 350, 420, 410,
510, 500)), .Names = c("com", "d", "strf", "side", "auf",
"zud", "dru"), row.names = c(NA, 60L), class = "data.frame")
这个代码:
s <- ggplot( data2 , aes(zud, dru))
s + geom_point(aes( shape=com, size=strf, fill=as.factor(d)) , alpha=0.5) +
scale_fill_hue( h=c(90, -100), l=seq(80, 20,length.out = 5 ), c=90) +
scale_size(range = c(2 , 10)) +
ylim(100, 700) + scale_shape_manual(values=c(21,22)) +
facet_grid(side ~ auf) +
guides(fill = guide_legend(override.aes = list(shape = 21, size=5)),
shape = guide_legend(override.aes = list( size=5)),
size = guide_legend(override.aes = list( shape=21, fill="grey70")))
这给了我这个正确的情节:
但是当我尝试通过更改此代码片段将正方形更改为三角形时
+ scale_shape_manual(values=c(21,22))
进入
+ scale_shape_manual(values=c(21,24))
形状的图例不正确(第二个形状为空)。
我应该怎么做才能得到这个填充形状的正确图例形状?(我在 Windows 64 位机器上运行 ggplot2' 版本 0.9.3.1 和 R 3.0.1)