我在绘制一些数据时遇到了一些问题:ggplot2
:我想在变量AdultInputProp
上使用facet_wrap
,但R没有找到变量,并且而是返回Error in as.quoted(facets) : object 'AdultInputProp' not found
。现在我明白,这仅仅意味着R无法在用于绘制的数据集中找到此变量,如果我要求ggplot2
改为使用相同变量创建shape
比例,那么它工作得很好。任何想法可能是什么问题?ggplot2 facet_wrap找不到变量,但形状确实
对不起,我不太清楚如何做一个最小的工作示例,从头开始生成df,所以这里是the df I'm using,代码如下。我也尝试使用facet_grid
而不是facet_wrap
,但遇到了同样的问题。
在这里与小面的代码返回上述错误:
df.plot.GBPperAIP <- ggplot(df.sum.GBPperAIP,
aes(x=TestIteration, y=Error,
colour=GoalBabblingProp,
group=interaction(GoalBabblingProp,
AdultInputProp))) +
facet_wrap(AdultInputProp) +
xlab("Step") + ylab("Mean error") + theme_bw(base_size=18) +
scale_colour_discrete(name = "Goal babbling proportion") +
geom_line(position = position_dodge(1000)) +
geom_errorbar(aes(ymin=Error-ci,
ymax=Error+ci),
color="black", width=1000,
position = position_dodge(1000)) +
geom_point(position = position_dodge(1000),
size=1.5, fill="white")
该其他代码,除了facet_wrap
线删除并shape
完全相同的添加正常工作:
df.plot.GBPperAIP <- ggplot(df.sum.GBPperAIP,
aes(x=TestIteration, y=Error,
colour=GoalBabblingProp,
shape=AdultInputProp,
group=interaction(GoalBabblingProp,
AdultInputProp))) +
xlab("Step") + ylab("Mean error") + theme_bw(base_size=18) +
scale_colour_discrete(name = "Goal babbling proportion") +
geom_line(position = position_dodge(1000)) +
geom_errorbar(aes(ymin=Error-ci,
ymax=Error+ci),
color="black", width=1000,
position = position_dodge(1000)) +
geom_point(position = position_dodge(1000),
size=1.5, fill="white")
'facet_wrap(〜AdultInputProp)' – eipi10