Reputation: 8172
My code:
x <-sample(1:1484)
y <-sample(1:1484)
library(hexbin)
cols <- colorRampPalette(c("darkorchid4","darkblue","green","yellow", "red") )
plot(hexbin(vel1,res1),colorcut = seq(0,1,length.out=24),colramp = function(n) cols(24))
Counts in the legend are from one to seven(e.g).How to include zero(white) in a legend?
Upvotes: 2
Views: 101
Reputation: 19454
You could change the mincnt
argument to 0
and add "white"
to the colramp
function, adjusting the number of colors returned from your cols
function:
plot(hexbin(x,y), colorcut = seq(0,1,length.out=24), mincnt = 0,
colramp = function(n) c("white", cols(n - 1)))
Upvotes: 2