我将pl1
使用ggplot在每个框上的点绘制一个4列矩阵的boxplot。绘图说明如下:
p1 <- ggplot(pl1, aes(x=factor(Edge_n), y=get(make.names(y_label)), ymax=max(get(make.names(y_label)))*1.05))+
geom_boxplot(aes(fill=method), outlier.shape= NA)+
theme(text = element_text(size=20), aspect.ratio=1)+
xlab("Number of edges")+
ylab(y_label)+
scale_fill_manual(values=color_box)+
geom_point(aes(x=factor(Edge_n), y=get(make.names(true_des)), ymax=max(get(make.names(true_des)))*1.05, color=method),
position = position_dodge(width=0.75))+
scale_color_manual(values=color_pnt)
然后,我将print(p1)
其打印在打开的pdf上。但是,这对我不起作用,并且出现以下错误:
Error in make.names(true_des) : object 'true_des' not found
有人可以帮忙吗?
您的示例不是很清楚,因为您进行了调用,但没有显示变量的值,因此很难弄清楚您要执行的操作(例如,是method
数据框中的列名)pl1
,或者它是一个变量(如果是变量,它的类型是什么?字符串是什么?名称?)。
尽管如此,这是一个示例,应该可以帮助您设置做自己想要的事情的方式:
尝试这样的事情:
pl1 <- data.frame(Edge_n = sample(5, 20, TRUE), foo = rnorm(20), bar = rnorm(20))
y_label <- 'foo'
ax <- do.call(aes, list(
x=quote(factor(Edge_n)),
y=as.name(y_label),
ymax = substitute(max(y)*1.05, list(y=as.name(y_label)))))
p1 <- ggplot(pl1) + geom_boxplot(ax)
print(p1)
这应该使您开始弄清楚其余的工作要做。
或者(对您的问题的不同解释)是,您可能在aes评估其参数的环境中遇到问题。有关详细信息,请参见https://github.com/hadley/ggplot2/issues/743。如果这是问题所在,那么答案可能会覆盖environment
参数的默认值aes
,例如:aes(x=factor(Edge_n), y=get(make.names(y_label)), ymax=max(get(make.names(y_label)))*1.05, environment=environment())
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句