Prevent title space changing when animating with descender letters

∥☆過路亽.° 提交于 2019-12-01 16:45:10

It looks like the title only gets the height of the text, and not the font's height, when reserving space for the title.

So you could instead use geom_text to place a title somewhere in the plot. For example, if I do:

ggplot(myDF, aes(x=x,y=y, label=frame)) +
   geom_point()+theme_gray() + 
   geom_text(x=2.5,y=5,aes(label=frame),adj=0)

(just as a ggplot, not animated yet...) I can see all the 2015's exactly overlapping, and the descenders of the month names are clearly there, and the text baseline is constant.

So if you can put your title in a handy space on the plot, you could use that, and use title_frame=FALSE in your gganimate.

I'd also consider a bug/enhancement report to ggplot2. If you make the title large enough it actually stomps on the plot:

ggplot(myDF, aes(x=x,y=y)) +geom_point()+theme(plot.title=element_text(size=rel(10),debug=TRUE)) + labs(title="y")

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!