Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R-在geom_箱线图(ggplot2)顶部绘制geom_点_R_Ggplot2_Fill_Boxplot_Points - Fatal编程技术网

R-在geom_箱线图(ggplot2)顶部绘制geom_点

R-在geom_箱线图(ggplot2)顶部绘制geom_点,r,ggplot2,fill,boxplot,points,R,Ggplot2,Fill,Boxplot,Points,我在ggplot2中的geom\u boxplot()层上绘制geom\u point()层时遇到问题,我做了一些研究,似乎没有任何报告的问题是这种性质的。我的数据集中有三个因素:名称、基因型、和地区,我的反应变量是体积。我有工作代码来生成两个图层的绘图。问题是这些点忽略了geom_point()的fill因子,而不是geom_boxplot()。其结果是,所有的点都被绘制在一组Box图的中间,每个值为名称< /代码>。这是我用来构建情节的代码 meansPlot = ggplot(data=m

我在
ggplot2
中的
geom\u boxplot()
层上绘制
geom\u point()
层时遇到问题,我做了一些研究,似乎没有任何报告的问题是这种性质的。我的数据集中有三个因素:
名称
基因型
、和
地区
,我的反应变量是
体积
。我有工作代码来生成两个图层的绘图。问题是这些点忽略了
geom_point()
fill
因子,而不是
geom_boxplot()
。其结果是,所有的点都被绘制在一组Box图的中间,每个值为<代码>名称< /代码>。这是我用来构建情节的代码

meansPlot = ggplot(data=meansData,aes(x=factor(name), y=volume, fill=factor(genotype)))
meansPlot = meansPlot + 
geom_boxplot() +
geom_point() +
facet_wrap( ~ region, scales='free')
很抱歉,我没有创建一个可复制的数据集——我还不太精通模拟数据。如果没有一个简单的答案(我希望会有,而且我可能只是遗漏了一些东西),我会添加模拟数据来帮助回答这个问题

谢谢

geom_point()
应使用
color
属性,而不是
fill
属性(除非您使用的是异常的
形状
s)。看看这是否适合您:

meansPlot = ggplot(data=meansData,aes(x=factor(name), y=volume, fill=factor(genotype)), color = factor(genotype))
meansPlot = meansPlot + 
geom_boxplot() +
geom_point() +
facet_wrap( ~ region, scales='free')

我最终基本上解决了这个问题。此代码交错
geom_point()
以与
geom_boxplot()
内联


感谢大家的努力。

填充
不适用于积分(通常),但
颜色
适用。因此,您必须对点使用
颜色
。此外,这可能是一个很好的参考(只需对箱线图使用
fill
),您可以查看不同的图符号。对于
pch
21-25,您可以指定填充颜色。感谢参考joran。结果证明它真的很有用。嗯,还是不起作用。有趣的是,现在至少有一些点具有正确的水平对齐。此外,每当绘制出绘图时,我都会收到以下警告:
警告级别
meansPlot = ggplot(data=meansData, aes(x=name, y=volume, fill=genotype, color=genotype))  
meansPlot = meansPlot +
geom_point(position=position_jitterdodge(dodge.width=0.9)) +
geom_boxplot(fill="white", position=position_dodge(width=0.9), alpha=0.5) +
facet_wrap( ~ region, scales='free')