如何解决'ymax未定义'? [英] How to solve the 'ymax not defined'?
问题描述
我正在尝试创建一个geom_bar:
<<< boring-plots,fig.width = 5 ,fig.height = 5,out.width ='。45'\\\ linewidth',fig.show ='hold',echo = FALSE,warning = FALSE>> =
ma_at_vs_t_duh + geom_bar(stat = bin,fill =white,color =darkgreen,width = .4)+ ggtitle(Anzahl MA nach Vertragsart,\ nMandant 10 und 50)+
theme(plot.title = element_text (lineheight = .6,face =bold))+
xlab(Vertragsart)+
ylab(Anzahl MA)+
theme(axis.title.x = element_text (vjust = 0.5,size = 14),axis.text.x = element_text(size = 10))+
stat_bin(aes(label = .. count ..),geom =text,size = 4 ,vjust = -0.5)
@
编译完Rnw文件后,在pdf输出文件中:
ymax未定义:使用y调整位置
我很感激任何帮助。谢谢!
如果有人仍然对此感兴趣,可以添加 ymax = max(value)
,在ggplot的aes中,这会使'ymax not defined'警告消失。
由于ymax用于定义barplot的最大高度,因此我建议将其设置为比数据的最大值多一点y轴。
类似这样:
ggplot(df,aes(x = bla,y = blu,ymax = max(blu)* 1.05))+ geom_bar()
乘以1.05会给你5%的呼吸空间进行注释。
I'm trying to create a geom_bar with:
<<boring-plots, fig.width=5, fig.height=5, out.width='.45\\linewidth',fig.show='hold', echo=FALSE, warning=FALSE>>=
ma_at_vs_t_duh + geom_bar(stat="bin", fill="white", colour="darkgreen", width=.4) + ggtitle("Anzahl MA nach Vertragsart, \nMandant 10 und 50") +
theme(plot.title = element_text(lineheight=.6, face="bold")) +
xlab("Vertragsart") +
ylab("Anzahl MA") +
theme(axis.title.x = element_text(vjust=0.5, size=14), axis.text.x=element_text(size=10)) +
stat_bin(aes(label=..count..), geom="text", size=4, vjust=-0.5)
@
After compiling the Rnw-File I'm getting in the pdf-output file:
ymax not defined: adjusting position using y instead
I'd appreciate any help. thanks!
If anyone is still interested in this, you can add ymax = max(value)
, in the aes of ggplot, and that will make the 'ymax not defined' warning to go away.
Since ymax is used to define the max 'height' of a barplot for example, I would recommend to set to a bit more than the maximum value of your data in the y axis.
Something like this:
ggplot(df,aes(x=bla,y=blu,ymax=max(blu)*1.05))+geom_bar()
Multiplying by 1.05 gives you 5% breathing room for annotation.
这篇关于如何解决'ymax未定义'?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!