R 绘制比例问题 - ggplot 制作看起来像表格的图

问题描述

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

代码如下:

#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 with overlapping points

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

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

ggplot,only legend visible

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...