停止ggplot2将数据点放在轴极限之外? [英] stop ggplot2 from dropping data points outside of axis limits?

查看:213
本文介绍了停止ggplot2将数据点放在轴极限之外?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我制作了一个线图(例如时间序列)并设置了我的坐标轴限制,那么当点位于轴限制之外时,我希望该线继续离开图,然后返回到图下一个点在轴限制内。现在,似乎ggplot2会完全删除这些点,并给我一个错误:消息。

If I make a line plot (a time series, for example) and set my axis limits, I want the line to continue off the plot when points are outside of the axis limits, and then come back into the plot for the next point that is within the axis limits. Right now, it seems that ggplot2 will just drop the points completely and give me a an "Error:" message.

推荐答案

如果你通过缩小轴比例( scale_x_continuous(limits = ...))来限制轴,那么这就是预期的行为。通过调整比例,您可以定义哪些数据应该成为该图的一部分。如果你想使用所有的数据,但只需放大坐标轴的特定区域,就需要使用 coord_cartesian(xlim = ...,ylim = ...)代替。

If you limit your axes by reducing the axis scale (scale_x_continuous(limits=...)), then that is the expected behavior. By adjusting the scale, you are defining what data should be part of the plot. If you want to use all the data, but just zoom in on a particular region of the axes, you want to use coord_cartesian(xlim=..., ylim=...) instead.

这篇关于停止ggplot2将数据点放在轴极限之外?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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