How to insert a legend in grid.hexagons from hexbin in R -
how insert legend in example below?
library("grid") library("hexbin") set.seed(506) x <- rnorm(10000) y <- rnorm(10000) z <- rnorm(100) w <- rnorm(100) xmin = min(x, z) xmax = max(x, z) ymin = min(y, w) ymax = max(y, w) df <- data.frame(x, y) bin <- hexbin(df, xbins=30, xbnds= c(xmin, xmax) , ybnds= c(ymin, ymax)) graphic <- hboxplot(bin, xbnds= c(xmin, xmax) , ybnds= c(ymin, ymax)) pushhexport(graphic) grid.hexagons(bin, border = gray(.7)) grid.points(z, w, pch=20, gp=gpar(col="blue")) #z , w others data vectors plot points on de grid.hexagons. upviewport()
i tried grid.hexlegend
not worked me, maybe did not done right.
i appreciate help.
Comments
Post a Comment