如何在点之间添加线而不“接触”点,如“type=”b“”?
我想在 R 绘图中的点之间添加线条。 但不是他们所有人之间。
所以我用“线”。 但我想保留“type='b'”样式,该行就在该点之前停止。
I would like to add lines between points in a plot in R.
But not between all of them.
So I use "lines".
But I would like to keep the "type='b'" style, with the line stopping just before the point.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您喜欢 ggplot,请尝试一下。 ggplot 本身并不支持基本图形中的
type = "b"
。我们可以通过一些过度绘制和子集来解决这个问题:If ggplot is your thing, give this a whirl. ggplot doesn't natively support the
type = "b"
as in base graphics. We can get around that though with some overplotting and subsetting:设置一些数据
使用所有点创建绘图
为某些点添加
type="b"
行:Set up some data
Create plot with all points
Add lines of
type="b"
for some of the points:您可以使用带有 type='c' 的lines 函数来仅添加点周围带有空格的线。只需将您有兴趣为其执行线条的子集提供给线条函数即可。
You can use the lines function with type='c' to just add the lines with the spaces around the points. Just give the lines function the subset that you are interested in doing the lines for.