boxplot如果我grid在绘图前面使用网格,我想向我的 中添加一个网格。我怎样才能把这个网格放在后面?
我正在使用的代码如下
library(dplyr)
input <- mtcars[,c('mpg','cyl')]
print(head(input))
boxplot(mpg ~ cyl, data = mtcars, xlab = "Number of Cylinders",
ylab = "Miles Per Gallon")
grid(nx=16, ny=16)
Run Code Online (Sandbox Code Playgroud) 我正在尝试在shapefile中创建一个网格,诸如此类。但是,我无法生成这样的网格。我想知道是否有人对如何实现这一目标有想法。
这是我的代码-
WWWL.Shape<- readOGR("E:/Juan Arango", "WWL_Commerce_OK")
WWWL.Shape
plot(WWWL.Shape)
proj4string(WWWL.Shape)
bb <- bbox(WWWL.Shape)
cs <- c(3.28084, 3.28084)*6000 # cell size
cc <- bb[, 1] + (cs/2) # cell offset
cd <- ceiling(diff(t(bb))/cs) # number of cells per direction
grd <- GridTopology(cellcentre.offset=cc, cellsize=cs, cells.dim=cd)
grd
sp_grd <- SpatialGridDataFrame(grd,
data=data.frame(id=1:prod(cd)),
proj4string=CRS(proj4string(WWWL.Shape)))
plot(sp_grd)
Run Code Online (Sandbox Code Playgroud)
输出 WWL.Shape
class : SpatialPolygonsDataFrame
features : 1
extent : 334367, 334498.7, 4088915, 4089057 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=15 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0
variables : 1 …Run Code Online (Sandbox Code Playgroud)