axi_dev: A graphic device that renders using the AxiDraw pen plooter

View source: R/device.R

axi_devR Documentation

A graphic device that renders using the AxiDraw pen plooter

Description

axi_dev() opens up a graphic device that takes plotting instructions from e.g. plot() or ggplot2, and renders it with the AxiDraw. ghost_dev() behaves like axi_dev(), but instead of sending instructions to the plotter it will collect them and allow you to preview the movement of the pen and send the instructions to the plotter at a later stage. For more complex plots it is adviced to use the asynchronous ghost_dev() as it makes it easier to pause and rewind the plot if something goes wrong or a pen runs dry.

Usage

axi_dev(
  paper_size = "A4",
  portrait = TRUE,
  margins = 20,
  tip_size = 1,
  color = "black",
  ignore_color = TRUE,
  ignore_lwd = FALSE,
  line_overlap = 0.1,
  min_overlap = -20,
  draw_fill = TRUE,
  fill_type = "hatch",
  circle_erode_threshold = 2,
  hatch_angle = 45,
  connect_hatch = TRUE,
  optimize_order = "all",
  instant = FALSE,
  pens = list(),
  options = axi_options()
)

ghost_dev(
  paper_size = "A4",
  portrait = TRUE,
  margins = 20,
  tip_size = 1,
  color = "black",
  ignore_color = TRUE,
  ignore_lwd = FALSE,
  line_overlap = 0.1,
  min_overlap = -20,
  draw_fill = TRUE,
  fill_type = "hatch",
  circle_erode_threshold = 2,
  hatch_angle = 45,
  connect_hatch = TRUE,
  optimize_order = "all",
  pens = list(),
  options = axi_options()
)

Arguments

paper_size

The size of the paper to draw on, either as a numeric vector giving dimensions in mm, or as a standard paper size name.

portrait

Logical. Is the paper oriented as portrait (i.e. width < height). Will rearrange given paper dimensions to fit.

margins

The margins of the paper, in mm. The spec follows that of css, meaning that if it is given as a single value it defines all margins, if given as two values it defines top/bottom, left/right, if it is given as three values it defines top, left/right, bottom, and if it is given as four values it defines top, right, bottom, left.

tip_size

The size of the tip (i.e. the width of the line it draws) of the initial pen

color

The color of the initial pen

ignore_color

Logical. Should changes in color output be ignored? If TRUE the plotter will not pause for pen change when the color changes

ignore_lwd

Logical. Should the device ignore the lwd and also just draw lines as a single pen stroke?

line_overlap

The overlap between adjacent pen strokes when filling out shapes and drawing thick lines, in mm. Setting this to a negative amount will cause gaps between the lines. If NA the overlap will be calculated from the color/fill alpha, scaled between min_overlap and 0.1.

min_overlap

The lower bound in mm of the overlap if it is being calculated from the color/fill alpha. Should be a negative value to ensure low alpha results in gapped hatching.

draw_fill

Logical. Should fill be drawn using hatching?

fill_type

How should shapes be filled? Either 'hatch' to fill with straight parallel line or 'erode' for filling with consecutively shrunken versions of the shape.

circle_erode_threshold

At which radius (in mm) should circles begin to be filled by erosion instead of hatching when fill_type = 'erode'?

hatch_angle

Angle in degrees that the hatching of fill should be drawn with. If NA a random angle will be chosen for each fill.

connect_hatch

Should hatches be connected if possible or should the pen be lifted between each hatch line?

optimize_order

Either 'all' to optimize the drawing order of all consecutive lines of the same color, 'primitive' to optimize the drawing order of lines from the same consecutive primitive (e.g. circle, segment, or polygon) of the same color, or 'none' to not do any optimization.

instant

Should plotting happen the instant a primitive is drawn or only when needed (before pen change, when finishing)

pens

One or more pen specifications created using pen().

options

An axi_options object. See the documentation for axi_options() for all the settings.

Details

At the moment the device does not support text. This will hopefully change in the future.

Examples

gd <- ghost_dev('A6')
par(mar = c(0, 0, 0, 0))
plot(cars)
lines(lowess(cars))
invisible(dev.off())

gd$preview(plot_air = TRUE)


thomasp85/fawkes documentation built on Jan. 27, 2024, 8:41 a.m.