【发布时间】:2016-01-29 13:40:22
【问题描述】:
为什么即使 x 比例没有超出范围,该数据中的行仍会在图中丢失并被删除?我试图包括 xlim 没有成功。我在这里想念什么?这是图中未包含的图形 Gp2 (geom_point)。我使用的代码如下:
df1 <- data.frame(x=c(2,4:8),
y=c(1.030928,4.123711,3.092784,8.247423,9.278351,4.123711))
df2 <- data.frame(x=3:8,
y=c(1.700680,1.360544,4.081633,3.401361,3.061224,9.183673))
require(ggplot2)
ggplot(NULL, aes(x=x, y=y)) +
geom_bar(data = df1, aes(fill="Gp1", shape="Gp1"),
stat= "identity") +
geom_point(data = df2, stat= "identity", size = 5,
aes(shape="Gp2", fill="Gp2")) +
ylab("%") + xlab("grades") +
ggtitle("Test figure") +
scale_shape_manual(values = c(23, NA)) +
scale_fill_manual(values = c("#6699CC","#000099")) +
guides(fill = guide_legend(reverse = TRUE),
shape = guide_legend(override.aes = list(shape=0), reverse = TRUE))
这会给出警告信息: 删除了 6 行包含缺失值 (geom_point)。
【问题讨论】: