如何在下面的示例中插入图例?
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 and w are others data vectors to plot as points over de grid.hexagons.
upViewport()
我试过了grid.hexlegend
,但它对我不起作用,也许我做得不对。
我感谢任何帮助。