ggplot2 – 两条垂直线之间的阴影区域

栏目: R语言 · 发布时间: 8年前

内容简介:http://stackoverflow.com/questions/9178024/ggplot2-shade-area-between-two-vertical-lines

我使用ggplot2创建一些相当简单的散点图.我目前有两条简单的垂直线:

... + geom_vline(xintercept=159684.186,linetype="dotted",size=0.6)+
geom_vline(xintercept=159683.438,linetype="dotted",size=0.6)+ ...

任何人都可以告诉我如何将这两条线之间的区域从Y轴的顶部遮蔽到X轴?

你可以使用geom_rect.

... + geom_rect(aes(xmin=159683.438, xmax=159684.186, ymin=0, ymax=Inf))

x的两个值来自您的geom_vline调用.使用ymin = 0将其下降到0; ymax = Inf将一直到轴的顶部.如果你希望它一直到x轴,而不是0,你可以使用ymin = -Inf.

一些注释:

如果它是按照几何的顺序进行的,那么这样做最好,以便它被绘制在其他部分之前(特别是散点图数据).

您可以将aes调用之外的填充颜色(填充审美)设置为固定值.我还会将透明度(alpha)设置为0.5,使其后面的东西(网格线,很可能,如果你把它作为第一个几何)仍然可以看出.

http://stackoverflow.com/questions/9178024/ggplot2-shade-area-between-two-vertical-lines


以上所述就是小编给大家介绍的《ggplot2 – 两条垂直线之间的阴影区域》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。

Data Structures and Algorithms in Python

Data Structures and Algorithms in Python

Michael T. Goodrich、Roberto Tamassia、Michael H. Goldwasser / John Wiley & Sons / 2013-7-5 / GBP 121.23

Based on the authors' market leading data structures books in Java and C++, this book offers a comprehensive, definitive introduction to data structures in Python by authoritative authors. Data Struct......一起来看看 《Data Structures and Algorithms in Python》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码