static.Rd
Create a static plot based on rasterly
object.
This function allows users to add axes, legends and other descriptive details when generating `rasterly` objects.
rasterlyGrob( rasterlyObj, xlim = NULL, ylim = NULL, xlab = NULL, ylab = NULL, main = NULL, sub = NULL, interpolate = FALSE, axes = TRUE, legend = TRUE, legend_label = NULL, legend_layer = 1, legend_main = NULL, axes_gpar = grid::gpar(col = "black", cex = 1), label_gpar = grid::gpar(col = "black", cex = 1), main_gpar = grid::gpar(col = "black", cex = 1.5), legend_gpar = grid::gpar(col = "black", cex = 1.5), name = NULL, gp = NULL, vp = NULL ) grid.rasterly( rasterlyObj, interpolate = FALSE, axes = TRUE, xlim = NULL, ylim = NULL, xlab = NULL, ylab = NULL, main = NULL, sub = NULL, legend = TRUE, legend_label = NULL, legend_layer = 1, legend_main = NULL, axes_gpar = grid::gpar(col = "black", cex = 1), label_gpar = grid::gpar(col = "black", cex = 1), main_gpar = grid::gpar(col = "black", cex = 1.5), legend_gpar = grid::gpar(col = "black", cex = 1.5), name = NULL, gp = NULL, vp = NULL, ... ) # S3 method for rasterly plot( x, y = NULL, xlim = NULL, ylim = NULL, xlab = NULL, ylab = NULL, main = NULL, legend_main = NULL, sub = NULL, interpolate = FALSE, axes = TRUE, legend = TRUE, legend_label = NULL, legend_layer = 1, new.page = TRUE, ... ) # S3 method for rasterly print(x, ...)
rasterlyObj | A |
---|---|
xlim | Numeric; the x limits (x1, x2) of the plot. Default is |
ylim | Numeric; the y limits (y1, y2) of the plot. Default is |
xlab | Character; the label to be used for the |
ylab | Character; the label to be used for the |
main | Character; the title to be used for the plot. Default is |
sub | sub Character; a subtitle for the plot. Default is |
interpolate | Logical. Linearly interpolates the image if |
axes | Logical; should axes be drawn? Default is |
legend | Logical. Show a figure legend? Default is |
legend_label | Character. The label to apply to the figure legend. Default is |
legend_layer | Numeric. Specify the layer level within the |
legend_main | Character. The main title to use within the figure legend. The default is |
axes_gpar | Object of class |
label_gpar | Object of class |
main_gpar | Object of class |
legend_gpar | Object of class |
name | Character. An identifier used to locate the |
gp | A |
vp | Object of class |
... | Other arguments to modify the display. |
x | A |
y | NULL, will be ignored. |
new.page | display on a new page or not. |
We provide three functions to produce static graphics, which is based on the API of grid
, plot
and print
.
grid
: The rasterlyGrob
and grid.rasterly
are the most flexible data structure.
These functions produce a **grob
** object. Users can modify the existing display by the functions provided by grid
.
plot.rasterly
: The usage of this S3 method is very similar to the classic plot
function.
Users can set axis limits via xlim
and ylim
, as well as the corresponding labels using xlab
and ylab
, among other attributes.
print.rasterly
: This S3 method returns only a basic image raster.
if(requireNamespace("grid")) { data <- data.frame(x = rnorm(1e6), y = rexp(1e6, 10)) # a rasterly object rasterlyObj <- data %>% rasterly(mapping = aes(x = x, y = y)) %>% rasterly_points() # Generate a grob rg <- rasterlyGrob(rasterlyObj) ## get the raster grob by `grid::getGrob()` grid::getGrob(rg, "raster") grid::grid.newpage() grid::grid.draw(rg) # or grid::grid.newpage() grid.rasterly(rasterlyObj) # or `plot` plot(rasterlyObj, xlab = "rnorm(1e6)", ylab = "rexp(1e6, 10)", main = "This is an arbitrary plot") # or simply print rasterlyObj ## it is equivalent to `print(rasterlyObj)` }