plot stars object, with subplots for each level of first non-spatial dimension, and customization of legend key
# S3 method for stars
plot(
x,
y,
...,
join_zlim = TRUE,
main = make_label(x, 1),
axes = FALSE,
downsample = TRUE,
nbreaks = 11,
breaks = "quantile",
col = grey(1:(nbreaks - 1)/nbreaks),
key.pos = get_key_pos(x, ...),
key.width = lcm(1.8),
key.length = 0.618,
reset = TRUE,
box_col = grey(0.8),
center_time = FALSE,
hook = NULL,
mfrow = NULL
)# S3 method for stars
image(
x,
...,
band = 1,
attr = 1,
asp = NULL,
rgb = NULL,
maxColorValue = ifelse(inherits(rgb, "data.frame"), 255, max(x[[attr]], na.rm = TRUE)),
xlab = if (!axes) "" else names(d)[1],
ylab = if (!axes) "" else names(d)[2],
xlim = st_bbox(extent)$xlim,
ylim = st_bbox(extent)$ylim,
text_values = FALSE,
text_color = "black",
axes = FALSE,
interpolate = FALSE,
as_points = FALSE,
key.pos = NULL,
logz = FALSE,
key.width = lcm(1.8),
key.length = 0.618,
add.geom = NULL,
border = NA,
useRaster = isTRUE(dev.capabilities()$rasterImage == "yes"),
extent = x
)
# S3 method for nc_proxy
plot(x, y, ..., downsample = get_downsample(dim(x)), max_times = 16)
# S3 method for stars_proxy
plot(x, y, ..., downsample = get_downsample(dim(x)))
object of class stars
ignored
further arguments: for plot
, passed on to image.stars
; for image
, passed on to image.default
or rasterImage
.
logical; if TRUE
, compute a single, joint zlim (color scale) for all subplots from x
character; subplot title prefix; use ""
to get only time, use NULL
to suppress subplot titles
logical; should axes and box be added to the plot?
logical or numeric; if TRUE
will try to plot not many more pixels than actually are visible, if FALSE
, no downsampling takes place, if numeric, the number of pixels/lines/bands etc that will be skipped; see Details.
number of color breaks; should be one more than number of colors. If missing and col
is specified, it is derived from that.
actual color breaks, or a method name used for classIntervals.
colors to use for grid cells, or color palette function
integer; side to plot a color key: 1 bottom, 2 left, 3 top, 4 right; set to NULL
to omit key. Ignored if multiple columns are plotted in a single function call. Default depends on plot size, map aspect, and, if set, parameter asp
.
amount of space reserved for width of the key (labels); relative or absolute (using lcm)
amount of space reserved for length of the key (labels); relative or absolute (using lcm)
logical; if FALSE
, keep the plot in a mode that allows adding further map elements; if TRUE
restore original mode after plotting
color for box around sub-plots; use 0
to suppress plotting of boxes around sub-plots.
logical; if TRUE
, sub-plot titles will show the center of time intervals, otherwise their start
NULL or function; hook function that will be called on every sub-plot.
length-2 integer vector with nrows, ncolumns of a composite plot, to override the default layout
integer; which band (dimension) to plot
integer; which attribute to plot
numeric; aspect ratio of image
integer; specify three bands to form an rgb composite. Experimental: rgb color table; see Details.
numeric; passed on to rgb
character; x axis label
character; y axis label
x axis limits
y axis limits
logical; print values as text on image?
character; color for printed text values
logical; when using rasterImage (rgb), should pixels be interpolated?
logical; for curvilinear or sheared grids: parameter passed on to st_as_sf, determining whether raster cells will be plotted as symbols (fast, approximate) or small polygons (slow, exact)
logical; if TRUE
, use log10-scale for the attribute variable. In that case, breaks
and at
need to be given as log10-values; see examples.
object of class sfc
, or list with arguments to plot
, that will be added to an image or sub-image
color used for cell borders (only in case x
is a curvilinear or rotated/sheared grid)
logical; use the rasterImage capabilities of the graphics device?
object which has a st_bbox
method; sets the plotting extent
integer; maximum number of time steps to attempt to plot.
Downsampling: a value for downsample
of 0: no downsampling, 1: after every dimension value (pixel/line/band), one value is skipped (half of the original resolution), 2: after every dimension value, 2 values are skipped (one third of the original resolution), etc.
To remove unused classes in a categorical raster, use the droplevels function.
When bitmaps show visual artefacts (Moiré effects), make sure that device png is used rather than ragg::agg_png
as the latter uses antialiasing for filled polygons which causes this; see also https://github.com/r-spatial/stars/issues/573 .
use of an rgb color table is experimental; see https://github.com/r-spatial/mapview/issues/208
when plotting a subsetted stars_proxy
object, the default value for argument downsample
will not be computed correctly, and has to be set manually.
when plotting a subsetted stars_proxy
object, the default value for argument downsample
will not be computed correctly, and has to be set manually.
tif = system.file("tif/L7_ETMs.tif", package = "stars")
x = read_stars(tif)
image(x, col = grey((3:9)/10))
image(x, rgb = c(1,3,5)) # rgb composite
Run the code above in your browser using DataLab