如何摆脱 ggplot 中的边界线 geom_hex
How to get rid of boundary lines in ggplot geom_hex
我真的很喜欢 ggplot 中的 hexbin 密度图的想法,并且我尽可能地尝试使用它(而不是 stat_bin2d 生成的方形 bin)。然而,六边形的边界有时很明显。例如,
d <- ggplot(钻石, aes(克拉, 价格))
d + stat_binhex()
在这张图片中,六边形的边界显示为小白线,这有时会干扰我构思图片中真实的 "density" 变化。
如果我使用 stat_bin2d,则根本不会显示边界线:
d <- ggplot(钻石, aes(克拉, 价格))
d + stat_bin2d()
所以我的问题是:
为什么显示六边形边界而不显示方形边界。
更重要的是,有没有办法做到stat_hexbin不显示边界线?
非常感谢!
旁白:我更喜欢在 ggplot 中绘制六边形密度图,而不是使用其他一些包,主要是因为我喜欢稍后向其添加其他层的灵活性。
使用 link 到 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()
我真的很喜欢 ggplot 中的 hexbin 密度图的想法,并且我尽可能地尝试使用它(而不是 stat_bin2d 生成的方形 bin)。然而,六边形的边界有时很明显。例如,
d <- ggplot(钻石, aes(克拉, 价格))
d + stat_binhex()
在这张图片中,六边形的边界显示为小白线,这有时会干扰我构思图片中真实的 "density" 变化。
如果我使用 stat_bin2d,则根本不会显示边界线:
d <- ggplot(钻石, aes(克拉, 价格))
d + stat_bin2d()
所以我的问题是:
为什么显示六边形边界而不显示方形边界。
更重要的是,有没有办法做到stat_hexbin不显示边界线?
非常感谢!
旁白:我更喜欢在 ggplot 中绘制六边形密度图,而不是使用其他一些包,主要是因为我喜欢稍后向其添加其他层的灵活性。
使用 link 到 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()