| nr_rect | R Documentation |
Draw rectangles on a native raster image
nr_rect(
nr,
x,
y,
w,
h,
fill = "black",
color = NA,
hjust = 0,
vjust = 0,
linewidth = 1,
use_alpha = TRUE
)
nr |
native raster image |
x, y |
coordinates of lower left corner of rectangle. [vector] |
w, h |
width and height of rectangle. [vector] |
fill |
interior fill color [vector] |
color |
outline color. Default: NA. [vector] |
hjust, vjust |
specify horizontal and vertical justification of the
handle on the |
linewidth |
Line linewidth. Default: 1. If |
use_alpha |
Use alpha channel when drawing? Logical. Default: TRUE |
Invisibly return the supplied native raster image which was been modified in-place
Other drawing functions:
nr_circle(),
nr_polygon(),
nr_polyline(),
nr_tri_mesh()
set.seed(1)
w <- 200
h <- 150
nr <- nr_new(w, h, 'grey80')
N <- 10
coords <- expand.grid(x = seq(2, w, length.out = N),
y = seq(2, h, length.out = N))
cols <- sample(grDevices::heat.colors(nrow(coords)))
nr_rect(
nr,
x = coords$x,
y = coords$y,
w = w/N - 1,
h = h/N - 1,
fill = cols
)
plot(nr)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.