Skip to contents

draw() is a generic function that renders a drawable or sketch object to the current graphics device using grid. Methods accept optional xlim/ylim arguments giving axis limits; if omitted, limits are computed from the object's points.

Usage

draw(object, ...)

Arguments

object

A drawable or sketch object.

...

Passed to methods, e.g. xlim/ylim.

See also

Other core structure: canvas(), drawable(), group(), sketch(), style(), xy()

Examples

draw(shape_circle(radius = 1))


s <- sketch() + shape_circle(radius = 1) + shape_blob(x = 2, radius = 0.5)
draw(s)


# an explicit xlim/ylim overrides both the sketch's own canvas and the
# range of its shapes' own points, useful for zooming in/out or padding
draw(shape_circle(radius = 1), xlim = c(-2, 2), ylim = c(-2, 2))


# a non-drawable object is ignored, with a warning, rather than erroring
draw("not a drawable")
#> Warning: Non-drawable objects ignored by draw()