0

我正在尝试根据一个序数和一个连续变量绘制二项分布(是/否)的比例图。不知何故,当包括连续的点作为点的颜色时,情节的外观发生了根本性的变化。有人可以帮助我如何包含第三个变量而不使情节变成下表的结果吗?

代码如下:

#making table with proportions of people who switch (1),
## after arsenic level and education.

educ_switch <- prop.table(table(welldata$educ[welldata$switch==1],
                                welldata$arsenic[welldata$switch==1],  
                                welldata$switch[welldata$switch==1]))
educ_switch <- as_data_frame(educ_switch, make.names=TRUE)

#remove observations where the proportion is 0

educ_switch1 <- educ_switch[which (educ_switch$proportion>0),]
p <- ggplot(educ_switch1, aes(x = educ, y=proportion))

如果我做p + geom_point()

我得到以下图片:

具有重叠点的ggplot

但是当我尝试通过着色来区分第三个变量时p + geom_point(aes(colour = arsenic))

我得到了这个看起来很奇怪的东西:

ggplot,只有图例可见

4

0 回答 0