Add shape layer to SpatialData plot
Usage
plotShape(
i = 1,
j = NULL,
assay = 1,
x = NULL,
as = c("border", "solid", "centroid"),
...
)Arguments
- i
Index or name of shape to plot.
- j
Index or name of coordinate transformation to use. If
NULL, the coordinate transformation will be inherited fromplotSpatialData().- assay
Character string; in case of
cdenoting a row name, specifies whichassaydata to use (seegetTable). (ignored whenxis aSpatialDataPoint).- x
SpatialDataobject. IfNULL, the object will be inherited fromplotSpatialData().- ...
Optional aesthetic arguments passed to
geom_sf.
Examples
x <- file.path("extdata", "blobs.zarr")
x <- system.file(x, package="spatialdataR")
x <- readSpatialData(x)
# shapes
p <- plotSpatialData(x)
a <- p + plotShape(i="blobs_polygons")
#> Coordinate system already present.
#> ℹ Adding new coordinate system, which will replace the existing one.
b <- p + plotShape(i="blobs_multipolygons")
#> Coordinate system already present.
#> ℹ Adding new coordinate system, which will replace the existing one.
c <- p + plotShape(i="blobs_circles")
#> Coordinate system already present.
#> ℹ Adding new coordinate system, which will replace the existing one.
patchwork::wrap_plots(a, b, c)
# layered
p +
plotShape("blobs_circles", fill="pink") +
plotShape("blobs_polygons", colour="red")
#> Coordinate system already present.
#> ℹ Adding new coordinate system, which will replace the existing one.
#> Coordinate system already present.
#> ℹ Adding new coordinate system, which will replace the existing one.
patchwork::wrap_plots(a, b)