rplot: Rasterly plot

Description Usage Arguments Details See Also Examples

View source: R/rplot.R

Description

rplot is created to generate rasterly plot quickly but with base plot design. It is convenient but lacks flexibility and rasterly is highly recommended for a more versatile method.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
rplot(x, y = NULL, ...)

## Default S3 method:
rplot(
  x,
  y = NULL,
  ...,
  plot_width = 600,
  plot_height = 600,
  x_range = NULL,
  y_range = NULL,
  background = "white",
  reduction_func = NULL,
  layout = NULL,
  glyph = NULL
)

Arguments

x, y

Coordinates x, y for the plot.

...

Other rasterly arguments to pass through.

plot_width

Integer. The width of the image to plot; must be a positive integer. A higher value indicates a higher resolution.

plot_height

Integer. The height of the image to plot; must be a positive integer. A higher value indicates a higher resolution.

x_range

Vector of type numeric. The range of x; it can be used to clip the image. For larger datasets, providing x_range may result in improved performance.

y_range

Vector of type numeric. The range of y; it can be used to clip the image. For larger datasets, providing y_range may result in improved performance.

background

Character. The background color of the image to plot.

reduction_func

Function. A reduction function is used to aggregate data points into their pixel representations. Currently supported reduction operators are sum, any, mean, m2, first, last, min and max. Default is sum. See details.

layout

Character. The method used to generate layouts for multiple images. The default is weighted. Useful for categorical data (i.e. "color" is provided via aes()). weighted specifies that the final raster should be a weighted combination of each (categorical) aggregation matrix. Conversely, cover indicates that the afterwards objects will be drawn on top of the previous ones.

glyph

Character. Currently, only "circle" and "square" are supported; as the size of the pixels increases, how should they spread out – should the pattern be circular or square? Other glyphs may be added in the future.

Details

rasterly arguments are passed through via .... But some of them are noticeable.

See Also

rasterly rasterly_points

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
if(requireNamespace("ggplot2")) {
  library(ggplot2)
  # `color` represents a variable here
  with(diamonds, 
       rplot(x = carat, y = price, color = color)
  )
  # `color` represents an actual color vector
  with(diamonds, 
       rplot(x = carat, y = price, color = fire_map)
  )
}

plotly/rasterly documentation built on June 9, 2020, 1:21 p.m.