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

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

问题描述

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

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天全站免登陆