r - 如何摆脱ggplot geom_hex中的边界线

标签 r ggplot2 hexagonal-tiles

我真的很喜欢 ggplot 中的 hexbin 密度图的想法,并且我尽可能地尝试使用它(而不是由 stat_bin2d 生成的方形 bin)。然而,六边形的边界有时是明显的。例如,

d <- ggplot(钻石,aes(克拉,价格))

d + stat_binhex()

enter image description here

在这张图片中,六边形的边界显示为小白线,这有时会干扰我想象图片中真实“密度”变化的尝试。

如果我使用 stat_bin2d,则根本不显示边界线:

d <- ggplot(钻石,aes(克拉,价格))

d + stat_bin2d()

enter image description here

所以我的问题是:

  • 为什么显示六边形边界而方形边界不显示。
  • 更重要的是,有没有办法在不显示边界线的情况下做 stat_hexbin ?

  • 非常感谢!

    旁白:我更喜欢在 ggplot 中做六边形密度图而不是使用其他一些包,主要是因为我喜欢稍后添加其他层的灵活性。

    最佳答案

    使用指向 ggplot2 multiple stat_binhex() plots with different color gradients in one image 的链接作为引用,我能够使用以下代码完成您的要求:

    d <- ggplot(diamonds, aes(carat, price))
    d + stat_binhex(aes(colour = ..count..))
    

    或者
    d <- ggplot(diamonds, aes(carat, price, colour = ..count..))
    d + stat_binhex()
    

    enter image description here

    关于r - 如何摆脱ggplot geom_hex中的边界线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34700648/

    相关文章:

    linux - 为什么 read.clipboard 在 R 中不起作用

    r 检查 Sys.time() 是否在一天中给定的时间间隔内

    regex - 路径变量的子串

    r - 在特定文件上使用 R 的内部 tar 函数

    r - 如何增加 ggplot R 中的轴标签文本大小?

    c++ - 在六边形网格上 : selecting tiles within a given radius of a selection point.

    r - 如何(最低限度地)调整 geom_text() 标签以避免在堆叠的 geom_col() 上重叠

    r - 在 ggplot 中平滑

    android - 使用六边形图像随机生成图案

    javascript - 六边形/形状中的随机点