如何更改 geom_hex() 数据的装箱方式?
有人可以向我指出如何使用 ..count..
以外的内容进行填充的示例吗?我有一个数据集,其中包含 [0,1] 上两个变量的超过 100k 个观察值和一组权重。我想制作一个散点图来显示数据的结构,而不依赖于样本。现在,我使用 alpha 进行重叠绘制,并使用权重大小,如下所示:
ggplot( data= cropScatDf, aes( agland, nomos1, size= weight)) + geom_point( alpha= 0.03) + scale_area( limits= c(0.7, 1), breaks= seq( 0.7, by= 0.1), to= c(0.7, 1) *6)
它工作正常,但视觉质量因我的 ggsave() 设置而异。所以现在我有了这个:
ggplot( data=cropScatDf, aes( agland, nomos1)) + stat_binhex( binwidth=c(0.05, 0.05)) + scale_fill_gradientn( colours= brewer.pal( 6, "YlGn"), trans= "log10", limits=c(100,50000))
这在显示结构方面做得非常好,但我希望能够说我已经将权重应用到了垃圾箱上,而不是仅仅接受直接计数。这可能吗?我想我没有掌握语法的一些微妙之处。有没有一种方法可以在将数据导入 ggplot() 之前对数据进行处理以获得所需的效果?我可以编写自己的变压器吗?
Could someone point me to an example of how to use something other than ..count..
for the fill? I have a data set with over 100k observations of two variables on [0,1] and a set of weights. I want to make a scatterplot that shows the structure of the data without relying on a sample. Right now I am using alpha for the overplotting and size for the weights like this:
ggplot( data= cropScatDf, aes( agland, nomos1, size= weight)) + geom_point( alpha= 0.03) + scale_area( limits= c(0.7, 1), breaks= seq( 0.7, by= 0.1), to= c(0.7, 1) *6)
And it works okay, but the visual quality varies depeding on my ggsave()
settings. So now I have this:
ggplot( data=cropScatDf, aes( agland, nomos1)) + stat_binhex( binwidth=c(0.05, 0.05)) + scale_fill_gradientn( colours= brewer.pal( 6, "YlGn"), trans= "log10", limits=c(100,50000))
and this does a pretty good job of showing the structure but I want to be able to say that I have applied the weights to the bins rather than just accepting a straight count. Is this possible? I imagine there is some subtlety of the grammar that I am not grasping. Is there a way that I can cook my data before bringing it to ggplot()
to get the desired effect? Can I write my own transformer?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论