避免沿ggplot中的轴裁剪点 [英] Avoid clipping of points along axis in ggplot

查看:68
本文介绍了避免沿ggplot中的轴裁剪点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在绘制一个时间序列,其中响应变量的平均值作为点(y轴)逐月(x轴).

I am plotting a time series with mean values of a response variable as points (y-axis) by month (x-axis).

位于x轴上的值(即0个值)被裁剪.我可以更改y轴的限制,以在0以下添加一些填充,但我不希望这样做.

Values lying on the x-axis (i.e. 0 values) are clipped. I can change the limits of the y-axis to include some padding below 0, but I prefer not to.

是否有办法在x轴的前面或顶部绘制这些0点?

Is there a way to plot these 0 points in front of, or on-top of the x-axis?

推荐答案

尝试一下,

q <- qplot(1:10,1:10,size=I(10)) + scale_y_continuous(expand=c(0,0))
gt <- ggplot_gtable(ggplot_build(q))
gt$layout$clip[gt$layout$name=="panel"] <- "off"
grid.draw(gt)

这篇关于避免沿ggplot中的轴裁剪点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆