调整hexbin图例中断 [英] Adjust hexbin legend breaks
本文介绍了调整hexbin图例中断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在此示例中,右侧的图例具有10个级别/类/中断.有人知道如何更改级别数吗?假设我想将其更改为5左右.
In this example of a hexbin plot, the legend on the right has 10 levels/classes/breaks. Does anyone know how to change the number of levels? Say I want to change it to 5 or something.
library(hexbin)
x=rnorm(1000, mean = 50, sd = 1)
y=rnorm(1000, mean = 30, sd = 0.5)
df <- data.frame(x,y)
#plot(df)
hb <- hexbin(x=df$x, df$y)
#hb <- hexbin(x=df$x, df$y,xbins=30)
#plot(hb)
gplot.hexbin(hb)
推荐答案
喜欢吗?
gplot.hexbin(hb,colorcut=5)
这与使用ggplot
大致相同.
library(ggplot2)
ggplot(df, aes(x,y))+
geom_hex(aes(fill=cut(..value..,breaks=pretty(..value..,n=5))),bins=15)+
scale_fill_manual("Count",values=grey((5:0)/6))
这篇关于调整hexbin图例中断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文