click_shape: Add shapes interactively in base 'R' graphics

View source: R/plot_extra.R

click_shapeR Documentation

Add shapes interactively in base R graphics

Description

Add shapes anywhere in a plot (including margins) with mouse click(s).

Usage

click_shape(
  shape = c("circle", "arrow", "rect", "cyl", "line", "poly"),
  corners = 3L,
  ...
)

Arguments

shape

type of shape; choices are 'box', 'arrow', 'line', 'poly', 'circle', and 'cyl'

corners

number of corners to draw if shape = 'poly'

...

additional arguments or graphical parameters passed to the shape functions

See Also

click_text, rect, arrows, rect, rect, segments, polygon, draw.circle, cylindrect

Examples

## Not run: 
op <- par(xpd = NA)
plot.new()
plot.window(0:1, 0:1, asp = 1)
click_shape('line') # a line segment
click_shape('arrow', col = 'blue', code = 2, lwd = 2, length = .15)
click_shape('rect', border = 'purple', col = 'pink', lwd = 2)
click_shape('rect', col = NULL, border = 'purple', lwd = 2)
click_shape('line', col = 'orange', lty = 3, lwd = 3)
click_shape('poly', corners = 5, border = 'green', col = 'orange')
click_shape('poly', corners = 3, border = 'red', col = 'yellow', lty = 1)
click_shape('cyl', col = 'orange')
click_shape('circle', col = 'orange', border = 'black', lty = 3, lwd = 3)
par(op)

## End(Not run)


raredd/plotr documentation built on Nov. 19, 2023, 4:09 a.m.