如何解决'ymax未定义'?

Seb*_*anS 8 r beamer ggplot2 knitr

我正在尝试创建一个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", 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) 
@
Run Code Online (Sandbox Code Playgroud)

在编译了Rnw-File之后我进入了pdf-output文件:

ymax not defined: adjusting position using y instead
Run Code Online (Sandbox Code Playgroud)

我很感激任何帮助.谢谢!

Sla*_*lak 23

如果有人仍然对此感兴趣,你可以ymax = max(value)在ggplot的aes中添加,这将使'ymax not defined'警告消失.

例如,由于ymax用于定义条形图的最大"高度",我建议设置为比y轴中数据的最大值多一点.

像这样的东西:

ggplot(df,aes(x=bla,y=blu,ymax=max(blu)*1.05))+geom_bar() 
Run Code Online (Sandbox Code Playgroud)

乘以1.05可为注释提供5%的喘息空间.