| Title: | Browser-Native 'WebGL' Rendering for R Graphics |
|---|---|
| Description: | Provides browser-native 'WebGL' rendering for R graphics through 'htmlwidgets'. The package supports grammar-style graphics workflows and renderer-ready specifications for dense analytical and scientific scenes, including point, line, trajectory, raster, vector, mesh, and surface layers, shader-driven display modes, timeline controls, structured views, selection metadata, and publication-oriented static export helpers. Rendering stays in the browser, and the core package remains cross-platform without requiring 'CUDA', 'Metal', or 'OpenCL' toolchains. |
| Authors: | Frederic Bertrand [cre, aut]
|
| Maintainer: | Frederic Bertrand <[email protected]> |
| License: | GPL-3 |
| Version: | 0.8.0 |
| Built: | 2026-06-06 23:14:48 UTC |
| Source: | https://github.com/fbertran/ggwebgl |
animation_spec() is a user-facing alias for ggwebgl_timeline(). It keeps
one canonical timeline contract while providing a concise name for animation
examples and adapter code.
animation_spec(...)animation_spec(...)
... |
Arguments passed to |
A ggwebgl_timeline list.
animation_spec(frames = 1:3, autoplay = FALSE)animation_spec(frames = 1:3, autoplay = FALSE)
ggWebGL exposes a renderer-adapter protocol for converting explicit
backend inputs into normalized primitive scenes. Backend-specific methods
must resolve semantics before the widget consumes the payload.
as_ggwebgl_spec(x, ...)as_ggwebgl_spec(x, ...)
x |
Input object. |
... |
Passed to method-specific implementations. |
A normalized ggWebGL renderer specification.
point_layer <- ggwebgl_layer_points( data.frame(x = c(0, 1), y = c(1, 0)), x = "x", y = "y" ) spec <- ggwebgl_spec(layers = list(point_layer)) as_ggwebgl_spec(spec)point_layer <- ggwebgl_layer_points( data.frame(x = c(0, 1), y = c(1, 0)), x = "x", y = "y" ) spec <- ggwebgl_spec(layers = list(point_layer)) as_ggwebgl_spec(spec)
xgeo_state object to a ggWebGL renderer specificationConvert an xgeo_state object to a ggWebGL renderer specification
## S3 method for class 'xgeo_state' as_ggwebgl_spec( x, embedding = NULL, primitive = c("points", "density", "surface"), lod = NULL, webgl = list(), labels = list(), point_size = 4, alpha = 0.85, ... )## S3 method for class 'xgeo_state' as_ggwebgl_spec( x, embedding = NULL, primitive = c("points", "density", "surface"), lod = NULL, webgl = list(), labels = list(), point_size = 4, alpha = 0.85, ... )
x |
An |
embedding |
Optional embedding name. Defaults to the active embedding. |
primitive |
Primitive family to project to renderer payloads. |
lod |
Optional LOD selector for |
webgl |
Renderer options passed through |
labels |
Optional labels list ( |
point_size |
Point size used for point payloads. |
alpha |
Alpha used for generated payload colors. |
... |
Reserved for future adapters. |
A normalized ggWebGL renderer specification.
toy_state <- list( attributes = list( embeddings = list( active = "toy", items = list( toy = list( coords = data.frame( point_id = paste0("p", 1:4), dim1 = c(0, 1, 0, 1), dim2 = c(0, 0, 1, 1) ) ) ) ), explanations = data.frame( point_id = paste0("p", 1:4), value = c(0.2, 0.4, 0.8, 0.5) ) ), metadata = list(title = "Toy backend state") ) class(toy_state) <- "xgeo_state" xgeo_spec <- as_ggwebgl_spec(toy_state, primitive = "points") xgeo_spec$render$primitives toy_state <- XGeoRTR::as_xgeo_state( data.frame( point_id = rep(paste0("p", 1:4), each = 2), feature = rep(c("f1", "f2"), times = 4), value = c(0.2, 0.7, 0.4, 0.1, 0.8, 0.6, 0.5, 0.3), x = c(0, 0, 1, 1, 0, 0, 1, 1), y = c(0, 0, 0, 0, 1, 1, 1, 1), z = 0 ), x_col = "x", y_col = "y", z_col = "z", value_col = "value", feature_col = "feature", point_id_col = "point_id" ) xgeo_spec <- as_ggwebgl_spec(toy_state, primitive = "points") xgeo_spec$render$primitivestoy_state <- list( attributes = list( embeddings = list( active = "toy", items = list( toy = list( coords = data.frame( point_id = paste0("p", 1:4), dim1 = c(0, 1, 0, 1), dim2 = c(0, 0, 1, 1) ) ) ) ), explanations = data.frame( point_id = paste0("p", 1:4), value = c(0.2, 0.4, 0.8, 0.5) ) ), metadata = list(title = "Toy backend state") ) class(toy_state) <- "xgeo_state" xgeo_spec <- as_ggwebgl_spec(toy_state, primitive = "points") xgeo_spec$render$primitives toy_state <- XGeoRTR::as_xgeo_state( data.frame( point_id = rep(paste0("p", 1:4), each = 2), feature = rep(c("f1", "f2"), times = 4), value = c(0.2, 0.7, 0.4, 0.1, 0.8, 0.6, 0.5, 0.3), x = c(0, 0, 1, 1, 0, 0, 1, 1), y = c(0, 0, 0, 0, 1, 1, 1, 1), z = 0 ), x_col = "x", y_col = "y", z_col = "z", value_col = "value", feature_col = "feature", point_id_col = "point_id" ) xgeo_spec <- as_ggwebgl_spec(toy_state, primitive = "points") xgeo_spec$render$primitives
as_mesh_webgl() converts CRAN-safe explicit mesh inputs into a lightweight
helper object accepted by ggwebgl_layer_mesh(). Core ggWebGL does not
convert external mesh package classes in this milestone.
as_mesh_webgl(x, ...)as_mesh_webgl(x, ...)
x |
Object to convert. Supported inputs are |
... |
Additional arguments passed to |
A ggwebgl_mesh object.
vertices <- data.frame(x = c(0, 1, 0), y = c(0, 0, 1), z = c(0, 0, 0)) triangles <- data.frame(i = 1L, j = 2L, k = 3L) as_mesh_webgl(list(vertices = vertices, triangles = triangles))vertices <- data.frame(x = c(0, 1, 0), y = c(0, 0, 1), z = c(0, 0, 0)) triangles <- data.frame(i = 1L, j = 2L, k = 3L) as_mesh_webgl(list(vertices = vertices, triangles = triangles))
Capture one or more ggWebGL scenes and assemble them into a single clean publication image.
compose_ggwebgl_figure( panels, file, width = 1800L, height = 1200L, format = NULL, dpi = 300, background = "white", layout = c("single", "row", "grid"), labels = NULL, inset = NULL, annotations = NULL, preset = c("clean", "publication"), selfcontained = FALSE, wait_seconds = 3, nrow = NULL, ncol = NULL, elementId = NULL )compose_ggwebgl_figure( panels, file, width = 1800L, height = 1200L, format = NULL, dpi = 300, background = "white", layout = c("single", "row", "grid"), labels = NULL, inset = NULL, annotations = NULL, preset = c("clean", "publication"), selfcontained = FALSE, wait_seconds = 3, nrow = NULL, ncol = NULL, elementId = NULL )
panels |
A list of panel sources. Each element may be a |
file |
Output file path. |
width, height
|
Output size in pixels. |
format |
Optional image format. When omitted, it is inferred from
|
dpi |
Output density metadata used when writing the image. |
background |
Background colour used for the final flattened image. |
layout |
One of |
labels |
Optional character vector of panel labels drawn in the top-left corner of each occupied panel cell. |
inset |
Optional list with a panel |
annotations |
Optional list of text annotations. Each entry should
contain |
preset |
Export preset. |
selfcontained |
Passed through to |
wait_seconds |
Default render delay before capture. |
nrow, ncol
|
Optional grid dimensions used when |
elementId |
Optional DOM element id passed when panel sources must first be turned into widgets. |
The normalized output file path, invisibly.
old <- options(ggwebgl.reset_processx_supervisor = TRUE) on.exit(options(old), add = TRUE) point_spec <- ggwebgl_spec( layers = list( ggwebgl_layer_points( data.frame(x = c(0.15, 0.48, 0.82), y = c(0.22, 0.76, 0.38)), x = "x", y = "y", colour = c("#0f766e", "#f97316", "#2563eb"), alpha = 0.8, size = 5 ) ), webgl = list(shader = "default", interactions = character()) ) line_spec <- ggwebgl_spec( layers = list( ggwebgl_layer_lines( data.frame(x = c(0.1, 0.45, 0.8), y = c(0.25, 0.75, 0.35)), x = "x", y = "y", colour = "#334155", alpha = 0.9, width = 2 ) ), webgl = list(shader = "default", interactions = character()) ) out <- tempfile(fileext = ".jpg") compose_ggwebgl_figure( panels = list( point_spec, line_spec ), file = out, layout = "row", labels = c("points", "lines"), width = 480, height = 240, format = "jpeg", preset = "clean", wait_seconds = 0.25 ) file.exists(out)old <- options(ggwebgl.reset_processx_supervisor = TRUE) on.exit(options(old), add = TRUE) point_spec <- ggwebgl_spec( layers = list( ggwebgl_layer_points( data.frame(x = c(0.15, 0.48, 0.82), y = c(0.22, 0.76, 0.38)), x = "x", y = "y", colour = c("#0f766e", "#f97316", "#2563eb"), alpha = 0.8, size = 5 ) ), webgl = list(shader = "default", interactions = character()) ) line_spec <- ggwebgl_spec( layers = list( ggwebgl_layer_lines( data.frame(x = c(0.1, 0.45, 0.8), y = c(0.25, 0.75, 0.35)), x = "x", y = "y", colour = "#334155", alpha = 0.9, width = 2 ) ), webgl = list(shader = "default", interactions = character()) ) out <- tempfile(fileext = ".jpg") compose_ggwebgl_figure( panels = list( point_spec, line_spec ), file = out, layout = "row", labels = c("points", "lines"), width = 480, height = 240, format = "jpeg", preset = "clean", wait_seconds = 0.25 ) file.exists(out)
coord_webgl_3d() is a ggplot-addable helper that marks the WebGL payload as
cartesian3d and installs a structured 3D view contract. It does not replace
ggplot2's 2D coordinate system; the standard ggplot object remains valid, and
the 3D interpretation is applied by ggplot_webgl(). Panel ranges and
fixed-scale facet metadata still come from ggplot2's built plot object.
coord_webgl_3d( projection = c("perspective", "orthographic"), camera = c("orbit", "trackball"), depth_test = TRUE, state = list() )coord_webgl_3d( projection = c("perspective", "orthographic"), camera = c("orbit", "trackball"), depth_test = TRUE, state = list() )
projection |
Projection mode, |
camera |
3D camera controller, |
depth_test |
Logical scalar; whether the browser renderer should enable depth testing for this scene. |
state |
Optional camera state list passed to |
A ggplot-addable ggwebgl_coord_3d object.
ggplot2::ggplot( data.frame(x = 1:3, y = 1:3, z = c(0, 1, 0)), ggplot2::aes(x, y, z = z) ) + geom_point_webgl() + coord_webgl_3d()ggplot2::ggplot( data.frame(x = 1:3, y = 1:3, z = c(0, 1, 0)), ggplot2::aes(x, y, z = z) ) + geom_point_webgl() + coord_webgl_3d()
Add a filled area layer tagged for the ggWebGL renderer. Stacking and
alignment are delegated to ggplot2; the WebGL layer consumes the built
ribbon boundaries.
geom_area_webgl( mapping = NULL, data = NULL, stat = "align", position = "stack", ..., orientation = NA, outline.type = "upper", lineend = "butt", linejoin = "round", linemitre = 10, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )geom_area_webgl( mapping = NULL, data = NULL, stat = "align", position = "stack", ..., orientation = NA, outline.type = "upper", lineend = "butt", linejoin = "round", linemitre = 10, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this layer.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Other arguments passed on to
|
orientation |
The orientation of the layer. The default ( |
outline.type |
Type of the outline of the area; |
lineend |
Line end style (round, butt, square). |
linejoin |
Line join style (round, mitre, bevel). |
linemitre |
Line mitre limit (number greater than 1). |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
A Layer ready for ggplot2.
area_data <- data.frame(x = 1:4, y = c(1, 2, 1, 3)) ggplot2::ggplot(area_data, ggplot2::aes(x, y)) + geom_area_webgl(fill = "#0f766e", alpha = 0.7)area_data <- data.frame(x = 1:4, y = c(1, 2, 1, 3)) ggplot2::ggplot(area_data, ggplot2::aes(x, y)) + geom_area_webgl(fill = "#0f766e", alpha = 0.7)
Add a bar layer tagged for the ggWebGL renderer. Counts and rectangle
boundaries are produced by ggplot2 through the selected stat and position.
geom_bar_webgl( mapping = NULL, data = NULL, stat = "count", position = "stack", ..., just = 0.5, lineend = "butt", linejoin = "mitre", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )geom_bar_webgl( mapping = NULL, data = NULL, stat = "count", position = "stack", ..., just = 0.5, lineend = "butt", linejoin = "mitre", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
Statistical transformation to use. Defaults to |
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Additional arguments forwarded through |
just |
Adjustment for column placement. Set to |
lineend |
Line end style (round, butt, square). |
linejoin |
Line join style (round, mitre, bevel). |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
A Layer ready for ggplot2.
bar_data <- data.frame(group = c("a", "a", "b", "c", "c", "c")) ggplot2::ggplot(bar_data, ggplot2::aes(group)) + geom_bar_webgl(fill = "#2563eb")bar_data <- data.frame(group = c("a", "a", "b", "c", "c", "c")) ggplot2::ggplot(bar_data, ggplot2::aes(group)) + geom_bar_webgl(fill = "#2563eb")
Add a 2D binned layer tagged for the ggWebGL renderer. Binning is delegated
to ggplot2::StatBin2d; the WebGL layer consumes the built rectangle
boundaries and count/density metadata.
geom_bin2d_webgl( mapping = NULL, data = NULL, stat = "bin2d", position = "identity", ..., lineend = "butt", linejoin = "mitre", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )geom_bin2d_webgl( mapping = NULL, data = NULL, stat = "bin2d", position = "identity", ..., lineend = "butt", linejoin = "mitre", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
Statistical transformation to use. Defaults to |
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Additional arguments forwarded through |
lineend |
Line end style (round, butt, square). |
linejoin |
Line join style (round, mitre, bevel). |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
A Layer ready for ggplot2.
bin_data <- data.frame( x = c(0.1, 0.2, 0.7, 1.2, 1.8, 2.1), y = c(0.1, 0.5, 0.6, 1.1, 1.3, 1.8) ) ggplot2::ggplot(bin_data, ggplot2::aes(x, y)) + geom_bin2d_webgl(binwidth = c(1, 1))bin_data <- data.frame( x = c(0.1, 0.2, 0.7, 1.2, 1.8, 2.1), y = c(0.1, 0.5, 0.6, 1.1, 1.3, 1.8) ) ggplot2::ggplot(bin_data, ggplot2::aes(x, y)) + geom_bin2d_webgl(binwidth = c(1, 1))
Add a boxplot layer tagged for the ggWebGL renderer. Boxplot statistics are
computed by ggplot2; the renderer serializes the built box body as
rectangles, medians/whiskers as pure segments, and outliers as points.
geom_boxplot_webgl( mapping = NULL, data = NULL, stat = "boxplot", position = "dodge2", ..., outliers = TRUE, outlier.colour = NULL, outlier.color = NULL, outlier.fill = NULL, outlier.shape = NULL, outlier.size = NULL, outlier.stroke = 0.5, outlier.alpha = NULL, whisker.colour = NULL, whisker.color = NULL, whisker.linetype = NULL, whisker.linewidth = NULL, staple.colour = NULL, staple.color = NULL, staple.linetype = NULL, staple.linewidth = NULL, median.colour = NULL, median.color = NULL, median.linetype = NULL, median.linewidth = NULL, box.colour = NULL, box.color = NULL, box.linetype = NULL, box.linewidth = NULL, notch = FALSE, notchwidth = 0.5, staplewidth = 0, varwidth = FALSE, na.rm = FALSE, orientation = NA, show.legend = NA, inherit.aes = TRUE )geom_boxplot_webgl( mapping = NULL, data = NULL, stat = "boxplot", position = "dodge2", ..., outliers = TRUE, outlier.colour = NULL, outlier.color = NULL, outlier.fill = NULL, outlier.shape = NULL, outlier.size = NULL, outlier.stroke = 0.5, outlier.alpha = NULL, whisker.colour = NULL, whisker.color = NULL, whisker.linetype = NULL, whisker.linewidth = NULL, staple.colour = NULL, staple.color = NULL, staple.linetype = NULL, staple.linewidth = NULL, median.colour = NULL, median.color = NULL, median.linetype = NULL, median.linewidth = NULL, box.colour = NULL, box.color = NULL, box.linetype = NULL, box.linewidth = NULL, notch = FALSE, notchwidth = 0.5, staplewidth = 0, varwidth = FALSE, na.rm = FALSE, orientation = NA, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
Statistical transformation to use. Defaults to |
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Additional arguments forwarded through |
outliers |
Whether to display ( |
outlier.colour, outlier.color, outlier.fill, outlier.shape, outlier.size, outlier.stroke, outlier.alpha
|
Default aesthetics for outliers. Set to |
whisker.colour, whisker.color, whisker.linetype, whisker.linewidth
|
Default aesthetics for the whiskers. Set to |
staple.colour, staple.color, staple.linetype, staple.linewidth
|
Default aesthetics for the staples. Set to |
median.colour, median.color, median.linetype, median.linewidth
|
Default aesthetics for the median line. Set to |
box.colour, box.color, box.linetype, box.linewidth
|
Default aesthetics for the boxes. Set to |
notch |
If |
notchwidth |
For a notched box plot, width of the notch relative to
the body (defaults to |
staplewidth |
The relative width of staples to the width of the box. Staples mark the ends of the whiskers with a line. |
varwidth |
If |
na.rm |
If |
orientation |
The orientation of the layer. The default ( |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
A Layer ready for ggplot2.
box_data <- data.frame(group = rep(c("a", "b"), each = 6), value = c(1:6, 2:7)) ggplot2::ggplot(box_data, ggplot2::aes(group, value, fill = group)) + geom_boxplot_webgl()box_data <- data.frame(group = rep(c("a", "b"), each = 6), value = c(1:6, 2:7)) ggplot2::ggplot(box_data, ggplot2::aes(group, value, fill = group)) + geom_boxplot_webgl()
Add a line-contour layer tagged for the ggWebGL renderer. Contour
generation is delegated to ggplot2::StatContour; this layer serializes the
built contour paths as grouped WebGL line primitives. Filled contours are not
rendered by this layer.
geom_contour_webgl( mapping = NULL, data = NULL, stat = "contour", position = "identity", ..., bins = NULL, binwidth = NULL, breaks = NULL, arrow = NULL, arrow.fill = NULL, lineend = "butt", linejoin = "round", linemitre = 10, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )geom_contour_webgl( mapping = NULL, data = NULL, stat = "contour", position = "identity", ..., bins = NULL, binwidth = NULL, breaks = NULL, arrow = NULL, arrow.fill = NULL, lineend = "butt", linejoin = "round", linemitre = 10, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this layer.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Other arguments passed on to
|
bins |
Number of contour bins. Overridden by |
binwidth |
The width of the contour bins. Overridden by |
breaks |
One of:
Overrides |
arrow |
Arrow specification, as created by |
arrow.fill |
fill colour to use for the arrow head (if closed). |
lineend |
Line end style (round, butt, square). |
linejoin |
Line join style (round, mitre, bevel). |
linemitre |
Line mitre limit (number greater than 1). |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
A Layer ready for ggplot2.
grid <- expand.grid(x = seq(-1, 1, length.out = 5), y = seq(-1, 1, length.out = 5)) grid$z <- with(grid, x^2 - y^2) ggplot2::ggplot(grid, ggplot2::aes(x, y, z = z)) + geom_contour_webgl(bins = 4)grid <- expand.grid(x = seq(-1, 1, length.out = 5), y = seq(-1, 1, length.out = 5)) grid$z <- with(grid, x^2 - y^2) ggplot2::ggplot(grid, ggplot2::aes(x, y, z = z)) + geom_contour_webgl(bins = 4)
Add a crossbar layer tagged for the ggWebGL renderer. Crossbars serialize
to one filled rectangle payload for the body and one pure segment payload for
the middle line.
geom_crossbar_webgl( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., middle.colour = NULL, middle.color = NULL, middle.linetype = NULL, middle.linewidth = NULL, box.colour = NULL, box.color = NULL, box.linetype = NULL, box.linewidth = NULL, na.rm = FALSE, orientation = NA, show.legend = NA, inherit.aes = TRUE )geom_crossbar_webgl( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., middle.colour = NULL, middle.color = NULL, middle.linetype = NULL, middle.linewidth = NULL, box.colour = NULL, box.color = NULL, box.linetype = NULL, box.linewidth = NULL, na.rm = FALSE, orientation = NA, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this layer.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Other arguments passed on to
|
middle.colour, middle.color, middle.linetype, middle.linewidth
|
Default aesthetics for the middle line. Set to |
box.colour, box.color, box.linetype, box.linewidth
|
Default aesthetics for the boxes. Set to |
na.rm |
If |
orientation |
The orientation of the layer. The default ( |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
A Layer ready for ggplot2.
crossbars <- data.frame(x = 1:3, y = c(2, 3, 2.5), ymin = c(1, 2, 1.8), ymax = c(3, 4, 3.2)) ggplot2::ggplot(crossbars, ggplot2::aes(x, y, ymin = ymin, ymax = ymax)) + geom_crossbar_webgl(width = 0.35, fill = "#93c5fd")crossbars <- data.frame(x = 1:3, y = c(2, 3, 2.5), ymin = c(1, 2, 1.8), ymax = c(3, 4, 3.2)) ggplot2::ggplot(crossbars, ggplot2::aes(x, y, ymin = ymin, ymax = ymax)) + geom_crossbar_webgl(width = 0.35, fill = "#93c5fd")
Add a density curve layer tagged for the ggWebGL renderer. Density
estimation is delegated to ggplot2::StatDensity; this geom serializes the
resulting curve as a line path. Filled densities are not rendered by this
layer.
geom_density_webgl( mapping = NULL, data = NULL, stat = "density", position = "identity", ..., outline.type = "upper", lineend = "butt", linejoin = "round", linemitre = 10, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )geom_density_webgl( mapping = NULL, data = NULL, stat = "density", position = "identity", ..., outline.type = "upper", lineend = "butt", linejoin = "round", linemitre = 10, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
Statistical transformation to use. Defaults to |
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Additional arguments forwarded through |
outline.type |
Type of the outline of the area; |
lineend |
Line end style (round, butt, square). |
linejoin |
Line join style (round, mitre, bevel). |
linemitre |
Line mitre limit (number greater than 1). |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
A Layer ready for ggplot2.
values <- data.frame(x = seq(-2, 2, length.out = 40)) ggplot2::ggplot(values, ggplot2::aes(x)) + geom_density_webgl(colour = "#0f766e")values <- data.frame(x = seq(-2, 2, length.out = 40)) ggplot2::ggplot(values, ggplot2::aes(x)) + geom_density_webgl(colour = "#0f766e")
Add a line-contour density layer tagged for the ggWebGL renderer. The 2D
density estimate and contour lines are computed by ggplot2; this layer
serializes the built contour paths as grouped WebGL line primitives. Filled
density contours are not rendered by this layer.
geom_density2d_webgl( mapping = NULL, data = NULL, stat = "density_2d", position = "identity", ..., contour_var = "density", lineend = "butt", linejoin = "round", linemitre = 10, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )geom_density2d_webgl( mapping = NULL, data = NULL, stat = "density_2d", position = "identity", ..., contour_var = "density", lineend = "butt", linejoin = "round", linemitre = 10, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
Statistical transformation to use. Defaults to |
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Additional arguments forwarded through |
contour_var |
Character string identifying the variable to contour
by. Can be one of |
lineend |
Line end style (round, butt, square). |
linejoin |
Line join style (round, mitre, bevel). |
linemitre |
Line mitre limit (number greater than 1). |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
A Layer ready for ggplot2.
density_points <- expand.grid(x = seq(-1, 1, length.out = 6), y = seq(-1, 1, length.out = 6)) if (requireNamespace("MASS", quietly = TRUE)) { ggplot2::ggplot(density_points, ggplot2::aes(x, y)) + geom_density2d_webgl(bins = 3) }density_points <- expand.grid(x = seq(-1, 1, length.out = 6), y = seq(-1, 1, length.out = 6)) if (requireNamespace("MASS", quietly = TRUE)) { ggplot2::ggplot(density_points, ggplot2::aes(x, y)) + geom_density2d_webgl(bins = 3) }
Add a vertical error-bar layer tagged for the ggWebGL renderer. The
renderer consumes ggplot2-built range and cap columns and serializes them
as pure segment primitives.
geom_errorbar_webgl( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., orientation = NA, lineend = "butt", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )geom_errorbar_webgl( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., orientation = NA, lineend = "butt", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this layer.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Other arguments passed on to
|
orientation |
The orientation of the layer. The default ( |
lineend |
Line end style (round, butt, square). |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
A Layer ready for ggplot2.
errors <- data.frame(x = 1:3, y = c(2, 3, 2.5), ymin = c(1, 2, 1.8), ymax = c(3, 4, 3.2)) ggplot2::ggplot(errors, ggplot2::aes(x, y, ymin = ymin, ymax = ymax)) + geom_errorbar_webgl(width = 0.2)errors <- data.frame(x = 1:3, y = c(2, 3, 2.5), ymin = c(1, 2, 1.8), ymax = c(3, 4, 3.2)) ggplot2::ggplot(errors, ggplot2::aes(x, y, ymin = ymin, ymax = ymax)) + geom_errorbar_webgl(width = 0.2)
Add a frequency polygon layer tagged for the ggWebGL renderer. Binning is
delegated to ggplot2::StatBin; the WebGL layer consumes the built path
coordinates.
geom_freqpoly_webgl( mapping = NULL, data = NULL, stat = "bin", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )geom_freqpoly_webgl( mapping = NULL, data = NULL, stat = "bin", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
Statistical transformation to use. Defaults to |
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Additional arguments forwarded through |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
A Layer ready for ggplot2.
values <- data.frame(x = c(0.1, 0.2, 0.7, 1.2, 1.6, 2.1)) ggplot2::ggplot(values, ggplot2::aes(x)) + geom_freqpoly_webgl(binwidth = 0.5, colour = "#2563eb")values <- data.frame(x = c(0.1, 0.2, 0.7, 1.2, 1.6, 2.1)) ggplot2::ggplot(values, ggplot2::aes(x)) + geom_freqpoly_webgl(binwidth = 0.5, colour = "#2563eb")
Add a histogram layer tagged for the ggWebGL renderer. Binning is delegated
to ggplot2::StatBin; the WebGL layer consumes the built bar rectangles.
geom_histogram_webgl( mapping = NULL, data = NULL, stat = "bin", position = "stack", ..., binwidth = NULL, bins = NULL, orientation = NA, lineend = "butt", linejoin = "mitre", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )geom_histogram_webgl( mapping = NULL, data = NULL, stat = "bin", position = "stack", ..., binwidth = NULL, bins = NULL, orientation = NA, lineend = "butt", linejoin = "mitre", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
Statistical transformation to use. Defaults to |
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Additional arguments forwarded through |
binwidth |
The width of the bins. Can be specified as a numeric value
or as a function that takes x after scale transformation as input and
returns a single numeric value. When specifying a function along with a
grouping structure, the function will be called once per group.
The default is to use the number of bins in The bin width of a date variable is the number of days in each time; the bin width of a time variable is the number of seconds. |
bins |
Number of bins. Overridden by |
orientation |
The orientation of the layer. The default ( |
lineend |
Line end style (round, butt, square). |
linejoin |
Line join style (round, mitre, bevel). |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
A Layer ready for ggplot2.
hist_data <- data.frame(x = c(0.1, 0.2, 0.7, 1.2, 1.6, 2.1)) ggplot2::ggplot(hist_data, ggplot2::aes(x)) + geom_histogram_webgl(binwidth = 0.5, fill = "#0f766e")hist_data <- data.frame(x = c(0.1, 0.2, 0.7, 1.2, 1.6, 2.1)) ggplot2::ggplot(hist_data, ggplot2::aes(x)) + geom_histogram_webgl(binwidth = 0.5, fill = "#0f766e")
Add label annotations tagged for the ggWebGL renderer. Labels are serialized
as text overlay metadata with background-box styling metadata; they are not
drawn as WebGL glyphs.
geom_label_webgl( mapping = NULL, data = NULL, stat = "identity", position = "nudge", ..., parse = FALSE, label.padding = grid::unit(0.25, "lines"), label.r = grid::unit(0.15, "lines"), border.colour = NULL, border.color = NULL, text.colour = NULL, text.color = NULL, size.unit = "mm", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )geom_label_webgl( mapping = NULL, data = NULL, stat = "identity", position = "nudge", ..., parse = FALSE, label.padding = grid::unit(0.25, "lines"), label.r = grid::unit(0.15, "lines"), border.colour = NULL, border.color = NULL, text.colour = NULL, text.color = NULL, size.unit = "mm", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this layer.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Other arguments passed on to
|
parse |
If |
label.padding |
Amount of padding around label. Defaults to 0.25 lines. |
label.r |
Radius of rounded corners. Defaults to 0.15 lines. |
border.colour, border.color
|
Colour of label border. When |
text.colour, text.color
|
Colour of the text. When |
size.unit |
How the |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
A Layer ready for ggplot2.
labels <- data.frame(x = c(1, 2), y = c(2, 1), label = c("A", "B")) ggplot2::ggplot(labels, ggplot2::aes(x, y, label = label)) + geom_point_webgl() + geom_label_webgl(fill = "#f8fafc", alpha = 0.9)labels <- data.frame(x = c(1, 2), y = c(2, 1), label = c("A", "B")) ggplot2::ggplot(labels, ggplot2::aes(x, y, label = label)) + geom_point_webgl() + geom_label_webgl(fill = "#f8fafc", alpha = 0.9)
Add a line layer that is tagged for the ggWebGL rendering pipeline. The
layer is drawn through the browser WebGL renderer when passed to
ggplot_webgl().
geom_line_webgl( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, orientation = NA, show.legend = NA, inherit.aes = TRUE )geom_line_webgl( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, orientation = NA, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this layer.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Other arguments passed on to
|
na.rm |
If |
orientation |
The orientation of the layer. The default ( |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
A Layer ready for ggplot2.
line_data <- data.frame( x = c(1, 2, 3, 1, 2, 3), y = c(1, 2, 1, 2, 3, 2), group = c("a", "a", "a", "b", "b", "b") ) line_plot <- ggplot2::ggplot( line_data, ggplot2::aes(x, y, group = group, colour = group) ) + geom_line_webgl(linewidth = 1) + theme_webgl(shader = "trajectory_age") line_plotline_data <- data.frame( x = c(1, 2, 3, 1, 2, 3), y = c(1, 2, 1, 2, 3, 2), group = c("a", "a", "a", "b", "b", "b") ) line_plot <- ggplot2::ggplot( line_data, ggplot2::aes(x, y, group = group, colour = group) ) + geom_line_webgl(linewidth = 1) + theme_webgl(shader = "trajectory_age") line_plot
Add a vertical range layer tagged for the ggWebGL renderer. The renderer
consumes ggplot2-built x, ymin, and ymax values and serializes ranges
as pure segment primitives.
geom_linerange_webgl( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., orientation = NA, lineend = "butt", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )geom_linerange_webgl( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., orientation = NA, lineend = "butt", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this layer.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Other arguments passed on to
|
orientation |
The orientation of the layer. The default ( |
lineend |
Line end style (round, butt, square). |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
A Layer ready for ggplot2.
ranges <- data.frame(x = 1:3, y = c(2, 3, 2.5), ymin = c(1, 2, 1.8), ymax = c(3, 4, 3.2)) ggplot2::ggplot(ranges, ggplot2::aes(x, y, ymin = ymin, ymax = ymax)) + geom_linerange_webgl(linewidth = 1)ranges <- data.frame(x = 1:3, y = c(2, 3, 2.5), ymin = c(1, 2, 1.8), ymax = c(3, 4, 3.2)) ggplot2::ggplot(ranges, ggplot2::aes(x, y, ymin = ymin, ymax = ymax)) + geom_linerange_webgl(linewidth = 1)
Add an unstructured triangle mesh layer tagged for the ggWebGL 3D renderer.
Mesh triangles are supplied with i, j, and k aesthetics using one-based
vertex indices.
geom_mesh_webgl( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., shading = c("mesh_lambert", "mesh_flat", "mesh_phong_simple", "mesh_scalar_colormap", "mesh_selection_highlight"), wireframe = FALSE, material = NULL, normals = NULL, pick_id = NULL, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )geom_mesh_webgl( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., shading = c("mesh_lambert", "mesh_flat", "mesh_phong_simple", "mesh_scalar_colormap", "mesh_selection_highlight"), wireframe = FALSE, material = NULL, normals = NULL, pick_id = NULL, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this layer.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Other arguments passed on to
|
shading |
Mesh shader mode. One of |
wireframe |
Whether to request a wireframe overlay. |
material |
Mesh material created by |
normals |
Optional vertex normals or |
pick_id |
Optional face picking ids. |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
A Layer ready for ggplot2.
vertices <- data.frame( x = c(0, 1, 0), y = c(0, 0, 1), z = c(0, 0, 0), i = c(1, NA, NA), j = c(2, NA, NA), k = c(3, NA, NA) ) ggplot2::ggplot(vertices, ggplot2::aes(x, y, z = z, i = i, j = j, k = k)) + geom_mesh_webgl()vertices <- data.frame( x = c(0, 1, 0), y = c(0, 0, 1), z = c(0, 0, 0), i = c(1, NA, NA), j = c(2, NA, NA), k = c(3, NA, NA) ) ggplot2::ggplot(vertices, ggplot2::aes(x, y, z = z, i = i, j = j, k = k)) + geom_mesh_webgl()
Add an ordered two-dimensional path layer tagged for the ggWebGL rendering
pipeline. Unlike geom_line_webgl(), this geom is based on
ggplot2::GeomPath and preserves row order within each group.
geom_path_webgl( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., lineend = "butt", linejoin = "round", linemitre = 10, arrow = NULL, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )geom_path_webgl( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., lineend = "butt", linejoin = "round", linemitre = 10, arrow = NULL, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this layer.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Other arguments passed on to
|
lineend |
Line end style (round, butt, square). |
linejoin |
Line join style (round, mitre, bevel). |
linemitre |
Line mitre limit (number greater than 1). |
arrow |
Arrow specification, as created by |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
A Layer ready for ggplot2.
path_data <- data.frame( x = c(3, 1, 2, 4), y = c(0.2, 0.8, 0.4, 0.6), frame = 1:4 ) path_plot <- ggplot2::ggplot( path_data, ggplot2::aes(x, y, frame = frame) ) + geom_path_webgl(linewidth = 1.2) + theme_webgl(shader = "trajectory_age") path_plotpath_data <- data.frame( x = c(3, 1, 2, 4), y = c(0.2, 0.8, 0.4, 0.6), frame = 1:4 ) path_plot <- ggplot2::ggplot( path_data, ggplot2::aes(x, y, frame = frame) ) + geom_path_webgl(linewidth = 1.2) + theme_webgl(shader = "trajectory_age") path_plot
Add an ordered three-dimensional path layer that is tagged for the ggWebGL
rendering pipeline. Unlike geom_line_webgl(), this geom is based on
ggplot2::GeomPath and preserves row order within each group.
geom_path3d_webgl( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., lineend = "butt", linejoin = "round", linemitre = 10, arrow = NULL, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )geom_path3d_webgl( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., lineend = "butt", linejoin = "round", linemitre = 10, arrow = NULL, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this layer.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Other arguments passed on to
|
lineend |
Line end style (round, butt, square). |
linejoin |
Line join style (round, mitre, bevel). |
linemitre |
Line mitre limit (number greater than 1). |
arrow |
Arrow specification, as created by |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
A Layer ready for ggplot2.
path_data <- data.frame( x = c(0, 0.4, 0.2, 0.8), y = c(0, 0.3, 0.7, 1), z = c(0, 0.2, 0.5, 0.9), frame = 1:4 ) path_plot <- ggplot2::ggplot( path_data, ggplot2::aes(x, y, z = z, frame = frame) ) + geom_path3d_webgl(linewidth = 1.2) + theme_webgl(shader = "trajectory_age") path_plotpath_data <- data.frame( x = c(0, 0.4, 0.2, 0.8), y = c(0, 0.3, 0.7, 1), z = c(0, 0.2, 0.5, 0.9), frame = 1:4 ) path_plot <- ggplot2::ggplot( path_data, ggplot2::aes(x, y, z = z, frame = frame) ) + geom_path3d_webgl(linewidth = 1.2) + theme_webgl(shader = "trajectory_age") path_plot
Add a point layer that is tagged for the ggWebGL rendering pipeline. The
layer is drawn through the browser WebGL renderer when passed to
ggplot_webgl().
geom_point_webgl( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )geom_point_webgl( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this layer.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Other arguments passed on to
|
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
A Layer ready for ggplot2.
point_plot <- ggplot2::ggplot( mtcars[1:8, ], ggplot2::aes(mpg, wt, colour = factor(cyl)) ) + geom_point_webgl(size = 2) + theme_webgl() point_plotpoint_plot <- ggplot2::ggplot( mtcars[1:8, ], ggplot2::aes(mpg, wt, colour = factor(cyl)) ) + geom_point_webgl(size = 2) + theme_webgl() point_plot
Add a point plus vertical range layer tagged for the ggWebGL renderer.
Pointranges serialize to one point payload and one pure segment payload.
geom_pointrange_webgl( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., orientation = NA, lineend = "butt", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )geom_pointrange_webgl( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., orientation = NA, lineend = "butt", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this layer.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Other arguments passed on to
|
orientation |
The orientation of the layer. The default ( |
lineend |
Line end style (round, butt, square). |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
A Layer ready for ggplot2.
ranges <- data.frame(x = 1:3, y = c(2, 3, 2.5), ymin = c(1, 2, 1.8), ymax = c(3, 4, 3.2)) ggplot2::ggplot(ranges, ggplot2::aes(x, y, ymin = ymin, ymax = ymax)) + geom_pointrange_webgl()ranges <- data.frame(x = 1:3, y = c(2, 3, 2.5), ymin = c(1, 2, 1.8), ymax = c(3, 4, 3.2)) ggplot2::ggplot(ranges, ggplot2::aes(x, y, ymin = ymin, ymax = ymax)) + geom_pointrange_webgl()
Add a simple polygon layer tagged for the ggWebGL renderer. The renderer
triangulates each ggplot2-built group as one simple, non-self-intersecting
ring and sends the result through the existing mesh primitive. Holes,
multipolygons, and self-intersections are not supported.
geom_polygon_webgl( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., rule = "evenodd", lineend = "butt", linejoin = "round", linemitre = 10, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )geom_polygon_webgl( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., rule = "evenodd", lineend = "butt", linejoin = "round", linemitre = 10, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this layer.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Other arguments passed on to
|
rule |
Either |
lineend |
Line end style (round, butt, square). |
linejoin |
Line join style (round, mitre, bevel). |
linemitre |
Line mitre limit (number greater than 1). |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
A Layer ready for ggplot2.
polygon_data <- data.frame( x = c(0, 1, 0.8, 0.2), y = c(0, 0.1, 1, 0.8) ) ggplot2::ggplot(polygon_data, ggplot2::aes(x, y)) + geom_polygon_webgl(fill = "#38bdf8", alpha = 0.7)polygon_data <- data.frame( x = c(0, 1, 0.8, 0.2), y = c(0, 0.1, 1, 0.8) ) ggplot2::ggplot(polygon_data, ggplot2::aes(x, y)) + geom_polygon_webgl(fill = "#38bdf8", alpha = 0.7)
Add a raster layer that is tagged for the ggWebGL rendering pipeline. The
layer is serialized into a texture-backed raster payload when passed to
ggplot_webgl().
geom_raster_webgl( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., hjust = 0.5, vjust = 0.5, interpolate = FALSE, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )geom_raster_webgl( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., hjust = 0.5, vjust = 0.5, interpolate = FALSE, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this layer.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Other arguments passed on to
|
hjust, vjust
|
horizontal and vertical justification of the grob. Each justification value should be a number between 0 and 1. Defaults to 0.5 for both, centering each pixel over its data location. |
interpolate |
If |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
A Layer ready for ggplot2.
raster_data <- expand.grid(x = 1:3, y = 1:2) raster_data$z <- with(raster_data, x + y) raster_plot <- ggplot2::ggplot( raster_data, ggplot2::aes(x, y, fill = z) ) + geom_raster_webgl(interpolate = TRUE) + ggplot2::scale_fill_gradient(low = "#0f172a", high = "#38bdf8") + theme_webgl() raster_plotraster_data <- expand.grid(x = 1:3, y = 1:2) raster_data$z <- with(raster_data, x + y) raster_plot <- ggplot2::ggplot( raster_data, ggplot2::aes(x, y, fill = z) ) + geom_raster_webgl(interpolate = TRUE) + ggplot2::scale_fill_gradient(low = "#0f172a", high = "#38bdf8") + theme_webgl() raster_plot
Add a rectangle layer tagged for the ggWebGL renderer. Boundaries are taken
from the data built by ggplot2, so xmin, xmax, ymin, and ymax
follow the same setup rules as ggplot2::geom_rect().
geom_rect_webgl( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., lineend = "butt", linejoin = "mitre", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )geom_rect_webgl( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., lineend = "butt", linejoin = "mitre", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this layer.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Other arguments passed on to
|
lineend |
Line end style (round, butt, square). |
linejoin |
Line join style (round, mitre, bevel). |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
A Layer ready for ggplot2.
rects <- data.frame( xmin = c(0, 1.2), xmax = c(0.8, 2), ymin = c(0, 0.4), ymax = c(1, 1.4), group = c("a", "b") ) ggplot2::ggplot( rects, ggplot2::aes(xmin = xmin, xmax = xmax, ymin = ymin, ymax = ymax, fill = group) ) + geom_rect_webgl(alpha = 0.7)rects <- data.frame( xmin = c(0, 1.2), xmax = c(0.8, 2), ymin = c(0, 0.4), ymax = c(1, 1.4), group = c("a", "b") ) ggplot2::ggplot( rects, ggplot2::aes(xmin = xmin, xmax = xmax, ymin = ymin, ymax = ymax, fill = group) ) + geom_rect_webgl(alpha = 0.7)
Add a filled ribbon layer tagged for the ggWebGL renderer. The renderer
consumes ggplot2-built x, ymin, and ymax values and draws each
group/run as a filled triangle strip.
geom_ribbon_webgl( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., orientation = NA, lineend = "butt", linejoin = "round", linemitre = 10, outline.type = "both", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )geom_ribbon_webgl( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., orientation = NA, lineend = "butt", linejoin = "round", linemitre = 10, outline.type = "both", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this layer.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Other arguments passed on to
|
orientation |
The orientation of the layer. The default ( |
lineend |
Line end style (round, butt, square). |
linejoin |
Line join style (round, mitre, bevel). |
linemitre |
Line mitre limit (number greater than 1). |
outline.type |
Type of the outline of the area; |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
A Layer ready for ggplot2.
ribbon_data <- data.frame( x = 1:4, ymin = c(0.1, 0.2, 0.1, 0.3), ymax = c(0.4, 0.7, 0.5, 0.8) ) ggplot2::ggplot(ribbon_data, ggplot2::aes(x, ymin = ymin, ymax = ymax)) + geom_ribbon_webgl(fill = "#38bdf8", alpha = 0.6)ribbon_data <- data.frame( x = 1:4, ymin = c(0.1, 0.2, 0.1, 0.3), ymax = c(0.4, 0.7, 0.5, 0.8) ) ggplot2::ggplot(ribbon_data, ggplot2::aes(x, ymin = ymin, ymax = ymax)) + geom_ribbon_webgl(fill = "#38bdf8", alpha = 0.6)
Add rug marks tagged for the ggWebGL renderer. Rug marks are serialized as
pure segment primitives with arrowheads disabled.
geom_rug_webgl( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., lineend = "butt", sides = "bl", outside = FALSE, length = grid::unit(0.03, "npc"), na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )geom_rug_webgl( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., lineend = "butt", sides = "bl", outside = FALSE, length = grid::unit(0.03, "npc"), na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this layer.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Other arguments passed on to
|
lineend |
Line end style (round, butt, square). |
sides |
A string that controls which sides of the plot the rugs appear on.
It can be set to a string containing any of |
outside |
logical that controls whether to move the rug tassels outside of the plot area. Default is off (FALSE). You will also need to use |
length |
A |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
A Layer ready for ggplot2.
rug_data <- data.frame(x = c(1, 2, 3), y = c(2, 1, 3)) ggplot2::ggplot(rug_data, ggplot2::aes(x, y)) + geom_point_webgl() + geom_rug_webgl(sides = "bl")rug_data <- data.frame(x = c(1, 2, 3), y = c(2, 1, 3)) ggplot2::ggplot(rug_data, ggplot2::aes(x, y)) + geom_point_webgl() + geom_rug_webgl(sides = "bl")
Add a pure line-segment layer tagged for the ggWebGL renderer. Segments use
the vector primitive with arrowheads disabled; use geom_vector_webgl() when
arrowheads are wanted.
geom_segment_webgl( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )geom_segment_webgl( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this layer.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Other arguments passed on to
|
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
A Layer ready for ggplot2.
segments <- data.frame( x = c(0, 1), y = c(0, 0.2), xend = c(0.8, 1.6), yend = c(0.7, 1) ) ggplot2::ggplot(segments, ggplot2::aes(x, y, xend = xend, yend = yend)) + geom_segment_webgl(linewidth = 1.2)segments <- data.frame( x = c(0, 1), y = c(0, 0.2), xend = c(0.8, 1.6), yend = c(0.7, 1) ) ggplot2::ggplot(segments, ggplot2::aes(x, y, xend = xend, yend = yend)) + geom_segment_webgl(linewidth = 1.2)
Add a rectilinear grid surface layer tagged for the ggWebGL structured
surface renderer. Surface layers are sent to WebGL as indexed triangles with
per-vertex positions, normals, colours, and surface metadata.
geom_surface_webgl( mapping = NULL, data = NULL, stat = StatSurfaceWebGL, position = "identity", ..., shading = c("surface_lambert", "surface_flat", "surface_height_colormap", "surface_uncertainty_alpha"), wireframe = FALSE, material = NULL, normals = "auto", contours = FALSE, contour_levels = NULL, contour_colour = "#1f2937", contour_width = 1, pick_id = NULL, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )geom_surface_webgl( mapping = NULL, data = NULL, stat = StatSurfaceWebGL, position = "identity", ..., shading = c("surface_lambert", "surface_flat", "surface_height_colormap", "surface_uncertainty_alpha"), wireframe = FALSE, material = NULL, normals = "auto", contours = FALSE, contour_levels = NULL, contour_colour = "#1f2937", contour_width = 1, pick_id = NULL, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this layer.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Other arguments passed on to
|
shading |
Surface shader mode. One of |
wireframe |
Whether to draw a wireframe overlay. |
material |
Surface material metadata created by |
normals |
Normal-generation mode. |
contours |
Whether to generate contour-line overlays on the R side. |
contour_levels |
Optional numeric contour levels. Defaults to |
contour_colour |
Contour line colour. |
contour_width |
Contour line width in renderer pixels. |
pick_id |
Optional triangle picking ids. |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
A Layer ready for ggplot2.
surface <- expand.grid(x = 1:3, y = 1:3) surface$z <- with(surface, sin(x) + cos(y)) ggplot2::ggplot(surface, ggplot2::aes(x, y, z = z, fill = z)) + geom_surface_webgl()surface <- expand.grid(x = 1:3, y = 1:3) surface$z <- with(surface, sin(x) + cos(y)) ggplot2::ggplot(surface, ggplot2::aes(x, y, z = z, fill = z)) + geom_surface_webgl()
Add static text labels tagged for the ggWebGL renderer. Text is serialized
as overlay metadata; it is not drawn as WebGL glyphs.
geom_text_webgl( mapping = NULL, data = NULL, stat = "identity", position = "nudge", ..., parse = FALSE, check_overlap = FALSE, size.unit = "mm", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )geom_text_webgl( mapping = NULL, data = NULL, stat = "identity", position = "nudge", ..., parse = FALSE, check_overlap = FALSE, size.unit = "mm", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this layer.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Other arguments passed on to
|
parse |
If |
check_overlap |
If |
size.unit |
How the |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
A Layer ready for ggplot2.
labels <- data.frame(x = c(1, 2), y = c(2, 1), label = c("left", "right")) ggplot2::ggplot(labels, ggplot2::aes(x, y, label = label)) + geom_point_webgl() + geom_text_webgl(vjust = -0.6)labels <- data.frame(x = c(1, 2), y = c(2, 1), label = c("left", "right")) ggplot2::ggplot(labels, ggplot2::aes(x, y, label = label)) + geom_point_webgl() + geom_text_webgl(vjust = -0.6)
Add a tile layer tagged for the ggWebGL renderer. Tile boundaries are read
from ggplot2's built layer data, which preserves geom_tile() width,
height, and irregular-spacing behavior.
geom_tile_webgl( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., lineend = "butt", linejoin = "mitre", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )geom_tile_webgl( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., lineend = "butt", linejoin = "mitre", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this layer.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Other arguments passed on to
|
lineend |
Line end style (round, butt, square). |
linejoin |
Line join style (round, mitre, bevel). |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
A Layer ready for ggplot2.
tiles <- expand.grid(x = 1:3, y = 1:2) tiles$value <- with(tiles, x + y) ggplot2::ggplot(tiles, ggplot2::aes(x, y, fill = value)) + geom_tile_webgl(alpha = 0.85)tiles <- expand.grid(x = 1:3, y = 1:2) tiles$value <- with(tiles, x + y) ggplot2::ggplot(tiles, ggplot2::aes(x, y, fill = value)) + geom_tile_webgl(alpha = 0.85)
Add a 2D or 3D vector-arrow layer tagged for the ggWebGL renderer.
geom_vector_webgl( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., head_size = 9, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )geom_vector_webgl( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., head_size = 9, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this layer.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Other arguments passed on to
|
head_size |
Arrowhead size in renderer pixels. |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
A Layer ready for ggplot2.
arrows <- data.frame(x = 1:3, y = 1:3, z = 0, xend = 1:3 + 0.3, yend = 1:3 + 0.2, zend = 0.2) ggplot2::ggplot(arrows, ggplot2::aes(x, y, z = z, xend = xend, yend = yend, zend = zend)) + geom_vector_webgl()arrows <- data.frame(x = 1:3, y = 1:3, z = 0, xend = 1:3 + 0.3, yend = 1:3 + 0.2, zend = 0.2) ggplot2::ggplot(arrows, ggplot2::aes(x, y, z = z, xend = xend, yend = yend, zend = zend)) + geom_vector_webgl()
Add a violin layer tagged for the ggWebGL renderer. Density estimation and
scaling are computed by ggplot2::stat_ydensity; the renderer converts each
built violin group to a mesh-backed filled strip. Quantile guide lines and
exact stroke parity with ggplot2::geom_violin() are not implemented.
geom_violin_webgl( mapping = NULL, data = NULL, stat = "ydensity", position = "dodge", ..., trim = TRUE, bounds = c(-Inf, Inf), scale = "area", na.rm = FALSE, orientation = NA, show.legend = NA, inherit.aes = TRUE )geom_violin_webgl( mapping = NULL, data = NULL, stat = "ydensity", position = "dodge", ..., trim = TRUE, bounds = c(-Inf, Inf), scale = "area", na.rm = FALSE, orientation = NA, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
Statistical transformation to use. Defaults to |
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Additional arguments forwarded through |
trim |
If |
bounds |
Known lower and upper bounds for estimated data. Default
|
scale |
if "area" (default), all violins have the same area (before trimming the tails). If "count", areas are scaled proportionally to the number of observations. If "width", all violins have the same maximum width. |
na.rm |
If |
orientation |
The orientation of the layer. The default ( |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
A Layer ready for ggplot2.
violin_data <- data.frame( group = rep(c("a", "b"), each = 24), value = c(seq(-1, 1, length.out = 24), seq(-0.4, 1.6, length.out = 24)) ) ggplot2::ggplot(violin_data, ggplot2::aes(group, value, fill = group)) + geom_violin_webgl(alpha = 0.65)violin_data <- data.frame( group = rep(c("a", "b"), each = 24), value = c(seq(-1, 1, length.out = 24), seq(-0.4, 1.6, length.out = 24)) ) ggplot2::ggplot(violin_data, ggplot2::aes(group, value, fill = group)) + geom_violin_webgl(alpha = 0.65)
Build a widget payload from a ggplot object. The current implementation
renders supported point, line, raster, and fixed-scale facet layouts through
the browser WebGL path while keeping unsupported layers explicit in the
payload.
ggplot_webgl(plot, width = NULL, height = NULL, elementId = NULL)ggplot_webgl(plot, width = NULL, height = NULL, elementId = NULL)
plot |
A |
width, height
|
Optional widget dimensions. |
elementId |
Optional DOM element id. |
An htmlwidget.
plot <- ggplot2::ggplot( mtcars[1:10, ], ggplot2::aes(mpg, wt, colour = factor(cyl)) ) + geom_point_webgl(size = 2) + theme_webgl(shader = "default") ggplot_webgl(plot, width = 420, height = 320)plot <- ggplot2::ggplot( mtcars[1:10, ], ggplot2::aes(mpg, wt, colour = factor(cyl)) ) + geom_point_webgl(size = 2) + theme_webgl(shader = "default") ggplot_webgl(plot, width = 420, height = 320)
Low-level constructor for the package widget binding.
ggWebGL(x = list(), width = NULL, height = NULL, elementId = NULL)ggWebGL(x = list(), width = NULL, height = NULL, elementId = NULL)
x |
Named list describing a widget payload. |
width, height
|
Optional widget dimensions passed through to
|
elementId |
Optional DOM element id. |
An htmlwidget.
point_layer <- ggwebgl_layer_points( data.frame(x = c(0, 1, 2), y = c(2, 1, 0)), x = "x", y = "y" ) spec <- ggwebgl_spec(layers = list(point_layer)) ggWebGL(spec, width = 320, height = 240)point_layer <- ggwebgl_layer_points( data.frame(x = c(0, 1, 2), y = c(2, 1, 0)), x = "x", y = "y" ) spec <- ggwebgl_spec(layers = list(point_layer)) ggWebGL(spec, width = 320, height = 240)
Read one of the packaged real-data subsets used by the examples, vignettes, and benchmark scripts.
ggwebgl_example_data( name = c("volcano_dem", "storm_tracks", "dense_embedding", "diamonds_embedding") )ggwebgl_example_data( name = c("volcano_dem", "storm_tracks", "dense_embedding", "diamonds_embedding") )
name |
Name of the example dataset to load. |
A data frame for CSV-backed datasets or the saved R object for
volcano_dem.
dem <- ggwebgl_example_data("volcano_dem") str(dem)dem <- ggwebgl_example_data("volcano_dem") str(dem)
Build a structured interaction specification for widget-owned hover, click,
brush/lasso, camera, and Shiny event behavior. Existing character
interactions vectors remain supported; this helper is the normalized
contract for new code.
ggwebgl_interactions( hover = TRUE, click = TRUE, brush = FALSE, lasso = FALSE, camera = TRUE, shiny = TRUE )ggwebgl_interactions( hover = TRUE, click = TRUE, brush = FALSE, lasso = FALSE, camera = TRUE, shiny = TRUE )
hover |
Enable hover picking and tooltip/event emission. |
click |
Enable click picking and event emission. |
brush |
Enable rectangular brush selection. |
lasso |
Enable lasso selection. |
camera |
Enable camera-state event emission for 3D interactions. |
shiny |
Enable Shiny event emission when a Shiny runtime is present. |
A ggwebgl_interactions list.
ggwebgl_interactions(brush = TRUE)ggwebgl_interactions(brush = TRUE)
Build a normalized line layer for downstream adapters.
ggwebgl_layer_lines( data, x, y, z = NULL, group = NULL, colour = NULL, rgba = NULL, alpha = NULL, width = NULL, age = NULL, frame = NULL, time = NULL, panel_id = 1L, geom = "adapter_lines" )ggwebgl_layer_lines( data, x, y, z = NULL, group = NULL, colour = NULL, rgba = NULL, alpha = NULL, width = NULL, age = NULL, frame = NULL, time = NULL, panel_id = 1L, geom = "adapter_lines" )
data |
Optional data frame supplying columns referenced by other arguments. |
x, y
|
Coordinate vectors or column names in |
z |
Optional z coordinate vector or column name for 3D scenes. |
group |
Optional path-group vector or column name. When omitted, all rows form one path. |
colour |
Optional colour vector or column name. Ignored when |
rgba |
Optional renderer-ready RGBA matrix/data frame with four columns,
or vector of length |
alpha |
Optional alpha vector or column name used with |
width |
Optional line-width vector or column name in renderer pixels. |
age |
Optional normalized age vector or column name in |
frame, time
|
Optional timeline frame or time vector or column name. |
panel_id |
Scalar panel identifier for this layer. |
geom |
Debug geom name recorded in the payload. |
A normalized line layer list.
lines <- data.frame( x = c(0, 1, 2, 0, 1, 2), y = c(0, 1, 0, 1, 2, 1), group = c("a", "a", "a", "b", "b", "b") ) ggwebgl_layer_lines( lines, x = "x", y = "y", group = "group", colour = "#334155", alpha = 0.75, width = 2 )lines <- data.frame( x = c(0, 1, 2, 0, 1, 2), y = c(0, 1, 0, 1, 2, 1), group = c("a", "a", "a", "b", "b", "b") ) ggwebgl_layer_lines( lines, x = "x", y = "y", group = "group", colour = "#334155", alpha = 0.75, width = 2 )
Build an indexed triangle mesh layer for downstream adapters. Triangle indices are supplied as one-based R indices and normalized to zero-based WebGL indices in the returned payload.
ggwebgl_layer_mesh( vertices, x = NULL, y = NULL, z = NULL, triangles = NULL, i = NULL, j = NULL, k = NULL, colour = NULL, rgba = NULL, alpha = NULL, id = NULL, scalar = NULL, normals = NULL, material = ggwebgl_material(), shading = NULL, pick_id = NULL, panel_id = 1L, geom = "adapter_mesh", wireframe = NULL )ggwebgl_layer_mesh( vertices, x = NULL, y = NULL, z = NULL, triangles = NULL, i = NULL, j = NULL, k = NULL, colour = NULL, rgba = NULL, alpha = NULL, id = NULL, scalar = NULL, normals = NULL, material = ggwebgl_material(), shading = NULL, pick_id = NULL, panel_id = 1L, geom = "adapter_mesh", wireframe = NULL )
vertices |
Data frame, |
x, y
|
Coordinate vectors or column names in |
z |
Optional z coordinate vector or column name. Defaults to zero. |
triangles |
Optional data frame supplying triangle index columns. |
i, j, k
|
One-based triangle index vectors or column names. |
colour |
Optional colour vector or column name. Ignored when |
rgba |
Optional renderer-ready RGBA matrix/data frame with four columns,
or vector of length |
alpha |
Optional alpha vector or column name used with |
id |
Optional stable primitive id vector or column name for selection. |
scalar |
Optional per-vertex scalar vector or column name. |
normals |
Optional vertex-normal matrix/data frame/vector or |
material |
Mesh material created by |
shading |
Optional mesh shader mode overriding |
pick_id |
Optional face picking ids. Length must be one or the number of triangles. |
panel_id |
Scalar panel identifier for this layer. |
geom |
Debug geom name recorded in the payload. |
wireframe |
Legacy shortcut for |
A normalized mesh layer list.
vertices <- data.frame(x = c(0, 1, 0), y = c(0, 0, 1), z = c(0, 0, 0)) triangles <- data.frame(i = 1L, j = 2L, k = 3L) ggwebgl_layer_mesh(vertices, x = "x", y = "y", z = "z", triangles = triangles)vertices <- data.frame(x = c(0, 1, 0), y = c(0, 0, 1), z = c(0, 0, 0)) triangles <- data.frame(i = 1L, j = 2L, k = 3L) ggwebgl_layer_mesh(vertices, x = "x", y = "y", z = "z", triangles = triangles)
Build a normalized point layer for downstream adapters. Inputs must already represent renderer coordinates and styling; package-specific semantics should be resolved before calling this helper.
ggwebgl_layer_points( data, x, y, z = NULL, colour = NULL, rgba = NULL, alpha = NULL, size = NULL, age = NULL, label = NULL, id = NULL, frame = NULL, time = NULL, panel_id = 1L, geom = "adapter_points" )ggwebgl_layer_points( data, x, y, z = NULL, colour = NULL, rgba = NULL, alpha = NULL, size = NULL, age = NULL, label = NULL, id = NULL, frame = NULL, time = NULL, panel_id = 1L, geom = "adapter_points" )
data |
Optional data frame supplying columns referenced by other arguments. |
x, y
|
Coordinate vectors or column names in |
z |
Optional z coordinate vector or column name for 3D scenes. |
colour |
Optional colour vector or column name. Ignored when |
rgba |
Optional renderer-ready RGBA matrix/data frame with four columns,
or vector of length |
alpha |
Optional alpha vector or column name used with |
size |
Optional point-size vector or column name in renderer pixels. |
age |
Optional normalized age vector or column name in |
label |
Optional hover label vector or column name. |
id |
Optional stable primitive id vector or column name for selection. |
frame, time
|
Optional timeline frame or time vector or column name. |
panel_id |
Scalar panel identifier for this layer. |
geom |
Debug geom name recorded in the payload. |
A normalized point layer list.
points <- data.frame( x = c(0, 1, 2), y = c(2, 1, 0), colour = c("#0f766e", "#f97316", "#2563eb"), label = c("a", "b", "c") ) ggwebgl_layer_points( points, x = "x", y = "y", colour = "colour", alpha = 0.6, size = 3, label = "label" )points <- data.frame( x = c(0, 1, 2), y = c(2, 1, 0), colour = c("#0f766e", "#f97316", "#2563eb"), label = c("a", "b", "c") ) ggwebgl_layer_points( points, x = "x", y = "y", colour = "colour", alpha = 0.6, size = 3, label = "label" )
Build a normalized raster layer from RGBA byte payloads.
ggwebgl_layer_raster( rgba, width, height, xmin, xmax, ymin, ymax, interpolate = FALSE, panel_id = 1L, geom = "adapter_raster" )ggwebgl_layer_raster( rgba, width, height, xmin, xmax, ymin, ymax, interpolate = FALSE, panel_id = 1L, geom = "adapter_raster" )
rgba |
Integer or numeric vector of length |
width, height
|
Raster dimensions in cells. |
xmin, xmax, ymin, ymax
|
Raster extent. |
interpolate |
Whether the WebGL texture should use linear filtering. |
panel_id |
Scalar panel identifier for this layer. |
geom |
Debug geom name recorded in the payload. |
A normalized raster layer list.
ggwebgl_layer_raster( rgba = rep(c(15L, 23L, 42L, 255L), 4L), width = 2L, height = 2L, xmin = 0, xmax = 1, ymin = 0, ymax = 1, interpolate = TRUE )ggwebgl_layer_raster( rgba = rep(c(15L, 23L, 42L, 255L), 4L), width = 2L, height = 2L, xmin = 0, xmax = 1, ymin = 0, ymax = 1, interpolate = TRUE )
Build a first-class structured-grid surface layer from a numeric matrix or
surface_matrix() object.
ggwebgl_layer_surface( z, x = NULL, y = NULL, colour = NULL, rgba = NULL, alpha = NULL, palette = "Terrain 2", shading = c("surface_lambert", "surface_flat", "surface_height_colormap", "surface_uncertainty_alpha"), normals = "auto", material = NULL, uncertainty = NULL, pick_id = NULL, panel_id = 1L, geom = "adapter_surface", wireframe = FALSE, contours = FALSE, contour_levels = NULL, contour_colour = "#1f2937", contour_width = 1 )ggwebgl_layer_surface( z, x = NULL, y = NULL, colour = NULL, rgba = NULL, alpha = NULL, palette = "Terrain 2", shading = c("surface_lambert", "surface_flat", "surface_height_colormap", "surface_uncertainty_alpha"), normals = "auto", material = NULL, uncertainty = NULL, pick_id = NULL, panel_id = 1L, geom = "adapter_surface", wireframe = FALSE, contours = FALSE, contour_levels = NULL, contour_colour = "#1f2937", contour_width = 1 )
z |
Numeric matrix or |
x, y
|
Optional coordinate vectors for matrix input. |
colour |
Optional colour vector. Ignored when |
rgba |
Optional renderer-ready RGBA matrix/data frame with four columns,
or vector of length |
alpha |
Optional alpha vector used with |
palette |
HCL palette used when neither |
shading |
Surface shader mode. |
normals |
Normal-generation mode. |
material |
Surface material created by |
uncertainty |
Optional per-vertex uncertainty values in |
pick_id |
Optional triangle picking ids. |
panel_id |
Scalar panel identifier. |
geom |
Debug geom name recorded in the payload. |
wireframe |
Whether to request a wireframe overlay. |
contours |
Whether to generate contour-line overlays on the R side. |
contour_levels |
Optional numeric contour levels. |
contour_colour |
Contour line colour. |
contour_width |
Contour line width in renderer pixels. |
A normalized structured surface layer list.
ggwebgl_layer_surface(volcano[1:4, 1:4])ggwebgl_layer_surface(volcano[1:4, 1:4])
Build a vector-arrow layer for downstream adapters.
ggwebgl_layer_vectors( data, x, y, xend, yend, z = NULL, zend = NULL, colour = NULL, rgba = NULL, alpha = NULL, width = NULL, head_size = NULL, id = NULL, frame = NULL, time = NULL, panel_id = 1L, geom = "adapter_vectors" )ggwebgl_layer_vectors( data, x, y, xend, yend, z = NULL, zend = NULL, colour = NULL, rgba = NULL, alpha = NULL, width = NULL, head_size = NULL, id = NULL, frame = NULL, time = NULL, panel_id = 1L, geom = "adapter_vectors" )
data |
Optional data frame supplying columns referenced by other arguments. |
x, y
|
Coordinate vectors or column names in |
xend, yend
|
Arrow endpoint coordinates. |
z |
Optional z coordinate vector or column name for 3D scenes. |
zend |
Optional arrow endpoint z coordinate for 3D scenes. When |
colour |
Optional colour vector or column name. Ignored when |
rgba |
Optional renderer-ready RGBA matrix/data frame with four columns,
or vector of length |
alpha |
Optional alpha vector or column name used with |
width |
Optional shaft width in renderer pixels. |
head_size |
Optional arrowhead size in renderer pixels. |
id |
Optional stable primitive id vector or column name for selection. |
frame, time
|
Optional timeline frame or time vector or column name. |
panel_id |
Scalar panel identifier for this layer. |
geom |
Debug geom name recorded in the payload. |
A normalized vector layer list.
arrows <- data.frame(x = 0:1, y = 0:1, xend = c(0.5, 1.4), yend = c(0.2, 1.2)) ggwebgl_layer_vectors(arrows, x = "x", y = "y", xend = "xend", yend = "yend")arrows <- data.frame(x = 0:1, y = 0:1, xend = c(0.5, 1.4), yend = c(0.2, 1.2)) ggwebgl_layer_vectors(arrows, x = "x", y = "y", xend = "xend", yend = "yend")
Create a deterministic zoom view from a rectangular data region. The helper is renderer-generic: callers provide renderer-ready ggWebGL sources and the selected region, and ggWebGL derives either a two-panel zoom spec or a publication figure with a linked inset.
ggwebgl_magnify_region( source, region, display = c("panel", "inset"), source_panel = NULL, zoom_layers = NULL, global_panel_id = "global", zoom_panel_id = "local", global_label = "Global", zoom_label = "Zoomed region", box = TRUE, box_colour = "#334155", box_alpha = 0.65, box_width = 1.5, inset = list(left = 0.68, top = 0.06, width = 0.24, height = 0.24), interactive = FALSE, width = NULL, height = NULL, background = "white", preset = c("clean", "publication"), labels = NULL, webgl = NULL )ggwebgl_magnify_region( source, region, display = c("panel", "inset"), source_panel = NULL, zoom_layers = NULL, global_panel_id = "global", zoom_panel_id = "local", global_label = "Global", zoom_label = "Zoomed region", box = TRUE, box_colour = "#334155", box_alpha = 0.65, box_width = 1.5, inset = list(left = 0.68, top = 0.06, width = 0.24, height = 0.24), interactive = FALSE, width = NULL, height = NULL, background = "white", preset = c("clean", "publication"), labels = NULL, webgl = NULL )
source |
A |
region |
Rectangle to magnify. Use either |
display |
One of |
source_panel |
Optional panel id to magnify when |
zoom_layers |
Optional renderer-ready layers to use in the zoom view. When omitted, the source panel layers are reused. |
global_panel_id, zoom_panel_id
|
Panel ids used in |
global_label, zoom_label
|
Optional panel labels. |
box |
Whether to add a rectangle overlay to the global panel. |
box_colour, box_alpha, box_width
|
Rectangle styling. |
inset |
Inset placement list for |
interactive |
Whether a two-panel magnifier should let browser-side brush rectangles on the global panel update the zoom panel viewport live. |
width, height
|
Optional publication figure dimensions for inset output. |
background, preset
|
Publication figure styling for inset output. |
labels |
Optional labels for the derived renderer specs. |
webgl |
Optional renderer options for the derived specs. Defaults to the source webgl options. |
A ggwebgl_spec for display = "panel" or a
ggwebgl_publication_figure for display = "inset".
source <- ggwebgl_spec( layers = list( ggwebgl_layer_points( data.frame(x = c(0, 1, 2, 3), y = c(0, 2, 1, 3)), x = "x", y = "y", colour = "#2563eb", alpha = 0.75, size = 4 ) ) ) ggwebgl_magnify_region( source, region = list(x = c(0.75, 2.25), y = c(0.75, 2.25)), display = "panel" )source <- ggwebgl_spec( layers = list( ggwebgl_layer_points( data.frame(x = c(0, 1, 2, 3), y = c(0, 2, 1, 3)), x = "x", y = "y", colour = "#2563eb", alpha = 0.75, size = 4 ) ) ) ggwebgl_magnify_region( source, region = list(x = c(0.75, 2.25), y = c(0.75, 2.25)), display = "panel" )
Build a renderer material specification for mesh and surface layers.
ggwebgl_material( shading = c("flat", "lambert", "mesh_flat", "mesh_lambert", "mesh_phong_simple", "mesh_scalar_colormap", "mesh_selection_highlight", "surface_flat", "surface_lambert", "surface_height_colormap", "surface_uncertainty_alpha"), ambient = 0.35, diffuse = 0.75, specular = 0, light_dir = c(0.35, 0.45, 0.82), wireframe = FALSE, cull = c("back", "none") )ggwebgl_material( shading = c("flat", "lambert", "mesh_flat", "mesh_lambert", "mesh_phong_simple", "mesh_scalar_colormap", "mesh_selection_highlight", "surface_flat", "surface_lambert", "surface_height_colormap", "surface_uncertainty_alpha"), ambient = 0.35, diffuse = 0.75, specular = 0, light_dir = c(0.35, 0.45, 0.82), wireframe = FALSE, cull = c("back", "none") )
shading |
Shading model. |
ambient, diffuse, specular
|
Lighting coefficients. |
light_dir |
Directional light vector. |
wireframe |
Whether to request a wireframe overlay. |
cull |
Face-culling mode, |
A ggwebgl_material list.
ggwebgl_material(shading = "lambert", wireframe = TRUE)ggwebgl_material(shading = "lambert", wireframe = TRUE)
Build a lightweight unstructured mesh object from explicit vertex and triangle tables.
ggwebgl_mesh( vertices, triangles, x = "x", y = "y", z = "z", i = "i", j = "j", k = "k", scalar = NULL, id = NULL, normals = NULL, colour = NULL, rgba = NULL, alpha = NULL, pick_id = NULL )ggwebgl_mesh( vertices, triangles, x = "x", y = "y", z = "z", i = "i", j = "j", k = "k", scalar = NULL, id = NULL, normals = NULL, colour = NULL, rgba = NULL, alpha = NULL, pick_id = NULL )
vertices |
Data frame with vertex coordinates. |
triangles |
Data frame with one-based triangle indices. |
x, y, z
|
Vertex coordinate column names. |
i, j, k
|
Triangle index column names. |
scalar |
Optional scalar column name or vector for per-vertex scalar colouring. |
id |
Optional vertex id column name or vector. |
normals |
Optional normal matrix/data frame/vector or column triplet
named |
colour, rgba, alpha
|
Optional vertex colour inputs passed through to
|
pick_id |
Optional face picking ids. |
A ggwebgl_mesh object.
vertices <- data.frame(x = c(0, 1, 0), y = c(0, 0, 1), z = c(0, 0, 0)) triangles <- data.frame(i = 1L, j = 2L, k = 3L) ggwebgl_mesh(vertices, triangles)vertices <- data.frame(x = c(0, 1, 0), y = c(0, 0, 1), z = c(0, 0, 0)) triangles <- data.frame(i = 1L, j = 2L, k = 3L) ggwebgl_mesh(vertices, triangles)
Create a package-owned HTML container for publication capture. Each child panel is rendered through ggWebGL in publication mode unless it already declares a different rendering contract explicitly.
ggwebgl_publication_figure( panels, layout = c("single", "row", "grid"), labels = NULL, annotations = NULL, inset = NULL, background = "white", preset = c("clean", "publication"), width = NULL, height = NULL )ggwebgl_publication_figure( panels, layout = c("single", "row", "grid"), labels = NULL, annotations = NULL, inset = NULL, background = "white", preset = c("clean", "publication"), width = NULL, height = NULL )
panels |
A non-empty list of panel sources. Supported sources are
|
layout |
One of |
labels |
Optional character vector of panel labels. |
annotations |
Optional list of figure-level text annotations. Each entry
should contain |
inset |
Optional inset specification containing a panel |
background |
Figure background colour. |
preset |
Publication styling preset. |
width, height
|
Optional figure dimensions in pixels. |
A browsable HTML container with class ggwebgl_publication_figure.
demo_spec <- ggwebgl_spec( layers = list( ggwebgl_layer_points( data.frame(x = c(0.15, 0.52, 0.84), y = c(0.20, 0.78, 0.42)), x = "x", y = "y", colour = c("#0f766e", "#f97316", "#2563eb"), alpha = 0.8, size = 5 ) ) ) figure <- ggwebgl_publication_figure( panels = list(demo_spec), width = 420, height = 280 ) inherits(figure, "ggwebgl_publication_figure")demo_spec <- ggwebgl_spec( layers = list( ggwebgl_layer_points( data.frame(x = c(0.15, 0.52, 0.84), y = c(0.20, 0.78, 0.42)), x = "x", y = "y", colour = c("#0f766e", "#f97316", "#2563eb"), alpha = 0.8, size = 5 ) ) ) figure <- ggwebgl_publication_figure( panels = list(demo_spec), width = 420, height = 280 ) inherits(figure, "ggwebgl_publication_figure")
Build a structured renderer-owned selection specification.
ggwebgl_selection( mode = c("none", "brush", "lasso", "brush_lasso"), highlight = TRUE, emit = TRUE )ggwebgl_selection( mode = c("none", "brush", "lasso", "brush_lasso"), highlight = TRUE, emit = TRUE )
mode |
Selection mode: |
highlight |
Whether selected primitives should be visibly highlighted. |
emit |
Whether selection payloads should be emitted to Shiny/callbacks. |
A ggwebgl_selection list.
ggwebgl_selection("brush_lasso")ggwebgl_selection("brush_lasso")
Build a ggWebGL Specification from Renderer-Ready Layers
ggwebgl_spec( layers, labels = list(), webgl = list(), grid = NULL, panels = NULL, messages = character(), timeline = NULL )ggwebgl_spec( layers, labels = list(), webgl = list(), grid = NULL, panels = NULL, messages = character(), timeline = NULL )
layers |
A list of normalized point, line, raster, vector, ribbon, mesh, or surface layers. |
labels |
Optional labels list ( |
webgl |
Optional renderer options passed to |
grid |
Optional list with |
panels |
Optional panel metadata list or data frame with |
messages |
Optional character vector of renderer messages. |
timeline |
Optional |
A classed ggwebgl_spec object accepted by ggWebGL().
panel_points <- ggwebgl_layer_points( data.frame(x = c(0, 1), y = c(1, 0)), x = "x", y = "y" ) panel_lines <- ggwebgl_layer_lines( data.frame(x = c(0, 1, 2), y = c(0, 1, 0)), x = "x", y = "y", panel_id = "B" ) spec <- ggwebgl_spec( layers = list(panel_points, panel_lines), labels = list(title = "adapter spec"), panels = data.frame( panel_id = c(1L, "B"), row = c(1L, 1L), col = c(1L, 2L), stringsAsFactors = FALSE ) ) spec$render$gridpanel_points <- ggwebgl_layer_points( data.frame(x = c(0, 1), y = c(1, 0)), x = "x", y = "y" ) panel_lines <- ggwebgl_layer_lines( data.frame(x = c(0, 1, 2), y = c(0, 1, 0)), x = "x", y = "y", panel_id = "B" ) spec <- ggwebgl_spec( layers = list(panel_points, panel_lines), labels = list(title = "adapter spec"), panels = data.frame( panel_id = c(1L, "B"), row = c(1L, 1L), col = c(1L, 2L), stringsAsFactors = FALSE ) ) spec$render$grid
Build a lightweight runtime timeline specification for animated
ggWebGL scenes. Layers can opt into timeline filtering with frame or
time fields.
ggwebgl_timeline( frames = NULL, time = NULL, duration = NULL, loop = TRUE, autoplay = FALSE, speed = 1, controls = TRUE, filter = c("exact", "cumulative"), values = NULL, source = c("auto", "frame", "time"), mode = NULL, fps = NULL )ggwebgl_timeline( frames = NULL, time = NULL, duration = NULL, loop = TRUE, autoplay = FALSE, speed = 1, controls = TRUE, filter = c("exact", "cumulative"), values = NULL, source = c("auto", "frame", "time"), mode = NULL, fps = NULL )
frames |
Optional integer frame values. |
time |
Optional numeric time values. |
duration |
Optional playback duration in seconds. |
loop |
Whether playback should loop. |
autoplay |
Whether playback should start automatically. |
speed |
Playback speed multiplier. |
controls |
Whether the widget should show timeline controls. |
filter |
Timeline visibility mode. |
values |
Optional frame or time values. Use |
source |
Timeline value source for |
mode |
Optional alias for |
fps |
Optional frames-per-second metadata for downstream controls. |
A ggwebgl_timeline list.
ggwebgl_timeline(frames = 1:4, autoplay = FALSE)ggwebgl_timeline(frames = 1:4, autoplay = FALSE)
ggwebgl_transport() controls how large renderer payloads are encoded before
they are handed to the browser. Small scenes keep the existing JSON arrays by
default; large point layers can use base64 typed arrays, palette color lookup,
deterministic preview LOD, and progressive GPU upload.
ggwebgl_transport( mode = c("auto", "compact", "legacy"), threshold = 100000L, progressive = c("auto", "on", "off"), chunk_size = 100000L, position = c("float32", "quantized"), colors = c("auto", "palette", "rgba"), lod = c("auto", "grid", "none"), lod_max_points = 5000L )ggwebgl_transport( mode = c("auto", "compact", "legacy"), threshold = 100000L, progressive = c("auto", "on", "off"), chunk_size = 100000L, position = c("float32", "quantized"), colors = c("auto", "palette", "rgba"), lod = c("auto", "grid", "none"), lod_max_points = 5000L )
mode |
Transport mode. |
threshold |
Row threshold used when |
progressive |
Progressive upload policy. |
chunk_size |
Number of points per progressive upload chunk. |
position |
Position encoding, either |
colors |
Color encoding. |
lod |
LOD preview policy. |
lod_max_points |
Maximum number of preview points generated by the grid LOD helper. |
A normalized ggwebgl_transport list.
ggwebgl_transport(threshold = 100000L, chunk_size = 50000L)ggwebgl_transport(threshold = 100000L, chunk_size = 50000L)
Build a structured renderer view specification. This replaces the previous
loose dimension, camera, projection, and camera_state
fields while keeping them mirrored internally for older renderer paths.
ggwebgl_view( dimension = c("2d", "3d"), projection = c("orthographic", "perspective"), controller = NULL, state = list() )ggwebgl_view( dimension = c("2d", "3d"), projection = c("orthographic", "perspective"), controller = NULL, state = list() )
dimension |
Renderer dimensionality, |
projection |
Projection mode, |
controller |
Interaction controller. Use |
state |
Camera/view state list. Recognized fields include |
A ggwebgl_view list.
ggwebgl_view(dimension = "3d", controller = "trackball")ggwebgl_view(dimension = "3d", controller = "trackball")
Shiny Output Binding for ggWebGL
ggWebGLOutput(outputId, width = "100%", height = "480px")ggWebGLOutput(outputId, width = "100%", height = "480px")
outputId |
Output variable to read from. |
width, height
|
Widget dimensions. |
A Shiny output tag.
ui <- shiny::fluidPage( ggWebGLOutput("plot", height = "320px") ) uiui <- shiny::fluidPage( ggWebGLOutput("plot", height = "320px") ) ui
Render a ggWebGL Widget in Shiny
renderGgWebGL(expr, env = parent.frame(), quoted = FALSE)renderGgWebGL(expr, env = parent.frame(), quoted = FALSE)
expr |
An expression returning a |
env |
Evaluation environment. |
quoted |
Whether |
A Shiny render function.
server <- function(input, output, session) { output$plot <- renderGgWebGL({ ggplot_webgl( ggplot2::ggplot( mtcars[1:8, ], ggplot2::aes(mpg, wt, colour = factor(cyl)) ) + geom_point_webgl(size = 2) + theme_webgl() ) }) } serverserver <- function(input, output, session) { output$plot <- renderGgWebGL({ ggplot_webgl( ggplot2::ggplot( mtcars[1:8, ], ggplot2::aes(mpg, wt, colour = factor(cyl)) ) + geom_point_webgl(size = 2) + theme_webgl() ) }) } server
scale_time_webgl() is not a visual ggplot2 scale. It records timeline
metadata for ggplot_webgl() so frame or time values can be normalized into
render$timeline.
scale_time_webgl( source = c("auto", "frame", "time"), values = NULL, mode = c("exact", "cumulative"), fps = NULL, speed = 1, loop = FALSE, label = NULL, format = NULL )scale_time_webgl( source = c("auto", "frame", "time"), values = NULL, mode = c("exact", "cumulative"), fps = NULL, speed = 1, loop = FALSE, label = NULL, format = NULL )
source |
Timeline column source. |
values |
Optional explicit timeline values. When omitted, values are
derived from built layer |
mode |
Timeline filtering intent: |
fps |
Optional frames-per-second metadata. |
speed |
Positive playback-speed multiplier. |
loop |
Whether future playback controls should loop. |
label |
Optional timeline label metadata. |
format |
Optional display-format metadata. |
An object that can be added to a ggplot.
df <- data.frame(x = c(0, 1, 2), y = c(0, 1, 0), frame = 1:3) plot <- ggplot2::ggplot(df, ggplot2::aes(x, y, frame = frame)) + geom_point_webgl() + scale_time_webgl(source = "frame", mode = "exact") plot$ggwebgl$time_scale$sourcedf <- data.frame(x = c(0, 1, 2), y = c(0, 1, 0), frame = 1:3) plot <- ggplot2::ggplot(df, ggplot2::aes(x, y, frame = frame)) + geom_point_webgl() + scale_time_webgl(source = "frame", mode = "exact") plot$ggwebgl$time_scale$source
Build a ggWebGL widget if needed, hide interactive chrome for export, and
capture a clean static image through the browser-backed widget path.
snapshot_ggwebgl( x, file, width = 1800L, height = 1200L, format = NULL, dpi = 300, background = "white", preset = c("clean", "publication"), selfcontained = FALSE, wait_seconds = 3, show_panel_overlay = FALSE, elementId = NULL )snapshot_ggwebgl( x, file, width = 1800L, height = 1200L, format = NULL, dpi = 300, background = "white", preset = c("clean", "publication"), selfcontained = FALSE, wait_seconds = 3, show_panel_overlay = FALSE, elementId = NULL )
x |
A |
file |
Output file path. |
width, height
|
Output size in pixels. |
format |
Optional image format. When omitted, it is inferred from
|
dpi |
Output density metadata used when writing the image. |
background |
Background colour used for the final flattened image. |
preset |
Export preset. |
selfcontained |
Passed through to |
wait_seconds |
Delay before capture to allow the widget to finish rendering. |
show_panel_overlay |
Whether facet/panel overlays should remain visible in the captured output. |
elementId |
Optional DOM element id passed when |
The normalized output file path, invisibly.
old <- options(ggwebgl.reset_processx_supervisor = TRUE) on.exit(options(old), add = TRUE) tiny_spec <- ggwebgl_spec( layers = list( ggwebgl_layer_points( data.frame(x = c(0.15, 0.5, 0.82), y = c(0.25, 0.78, 0.4)), x = "x", y = "y", colour = c("#0f766e", "#f97316", "#2563eb"), alpha = 0.8, size = 5 ) ), webgl = list(shader = "default", interactions = character()) ) out <- tempfile(fileext = ".jpg") snapshot_ggwebgl( tiny_spec, out, width = 320, height = 220, format = "jpeg", preset = "clean", wait_seconds = 0.25 ) file.exists(out)old <- options(ggwebgl.reset_processx_supervisor = TRUE) on.exit(options(old), add = TRUE) tiny_spec <- ggwebgl_spec( layers = list( ggwebgl_layer_points( data.frame(x = c(0.15, 0.5, 0.82), y = c(0.25, 0.78, 0.4)), x = "x", y = "y", colour = c("#0f766e", "#f97316", "#2563eb"), alpha = 0.8, size = 5 ) ), webgl = list(shader = "default", interactions = character()) ) out <- tempfile(fileext = ".jpg") snapshot_ggwebgl( tiny_spec, out, width = 320, height = 220, format = "jpeg", preset = "clean", wait_seconds = 0.25 ) file.exists(out)
Validate and order regular (x, y, z) triples for
geom_surface_webgl(). Missing or duplicate cells are rejected because
structured surfaces are triangulated without interpolation.
stat_surface_webgl( mapping = NULL, data = NULL, geom = GeomSurfaceWebGL, position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )stat_surface_webgl( mapping = NULL, data = NULL, geom = GeomSurfaceWebGL, position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
geom |
The geometric object to use to display the data for this layer.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Other arguments passed on to
|
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
A Layer ready for ggplot2.
surface <- expand.grid(x = 1:3, y = 1:3) surface$z <- with(surface, x * y) ggplot2::ggplot(surface, ggplot2::aes(x, y, z = z)) + stat_surface_webgl()surface <- expand.grid(x = 1:3, y = 1:3) surface$z <- with(surface, x * y) ggplot2::ggplot(surface, ggplot2::aes(x, y, z = z)) + stat_surface_webgl()
Create a structured surface-grid object from a numeric matrix. Rows map to
y, columns map to x, and the matrix values map to z.
surface_matrix(z, x = NULL, y = NULL)surface_matrix(z, x = NULL, y = NULL)
z |
Numeric matrix of height values. |
x |
Optional x-coordinate vector with one value per matrix column. |
y |
Optional y-coordinate vector with one value per matrix row. |
A ggwebgl_surface_matrix object accepted by
ggwebgl_layer_surface().
surface_matrix(volcano[1:3, 1:3])surface_matrix(volcano[1:3, 1:3])
Attach WebGL-specific rendering metadata to a ggplot object. The returned
object is consumed by ggplot_webgl() and stored on the plot as
plot$ggwebgl.
theme_webgl( shader = "default", antialias = TRUE, transparent = TRUE, buffer_size = 65536L, interactions = c("pan", "zoom"), interactions_spec = NULL, rendering = "visualization", panel_overlay = "auto", view = NULL, selection = NULL, dimension = "2d", camera = "orbit", projection = "orthographic", camera_state = list(), depth_test = NULL, blend_mode = "auto", timeline = NULL, transport = NULL, ... )theme_webgl( shader = "default", antialias = TRUE, transparent = TRUE, buffer_size = 65536L, interactions = c("pan", "zoom"), interactions_spec = NULL, rendering = "visualization", panel_overlay = "auto", view = NULL, selection = NULL, dimension = "2d", camera = "orbit", projection = "orthographic", camera_state = list(), depth_test = NULL, blend_mode = "auto", timeline = NULL, transport = NULL, ... )
shader |
Shader preset name or path identifier. Built-in modes include
point shaders ( |
antialias |
Logical scalar; whether antialiasing should be requested. |
transparent |
Logical scalar; whether the drawing surface should allow transparency. |
buffer_size |
Integer scalar giving the initial buffer allocation used by the eventual renderer. |
interactions |
Legacy character vector of interaction modes to enable.
New code should use |
interactions_spec |
Optional |
rendering |
Rendering contract mode. |
panel_overlay |
Panel overlay display mode. |
view |
Optional |
selection |
Optional |
dimension, camera, projection, camera_state
|
Legacy view fields retained as an internal migration shim. |
depth_test |
Logical scalar. |
blend_mode |
Primitive blending mode: |
timeline |
Optional |
transport |
Optional |
... |
Reserved for future backend-specific options. |
An object that can be added to a ggplot.
plot <- ggplot2::ggplot(mtcars, ggplot2::aes(mpg, wt, colour = factor(cyl))) + ggplot2::geom_point() + theme_webgl( shader = "density_splat", selection = ggwebgl_selection("none") ) plot$ggwebglplot <- ggplot2::ggplot(mtcars, ggplot2::aes(mpg, wt, colour = factor(cyl))) + ggplot2::geom_point() + theme_webgl( shader = "density_splat", selection = ggwebgl_selection("none") ) plot$ggwebgl
Send a timeline update message to a rendered ggWebGL widget. The browser
applies the update to the widget identified by outputId and emits the
updated state back as input$<outputId>_timeline.
updateGgWebGLTimeline( session, outputId, value = NULL, index = NULL, playing = NULL, speed = NULL, loop = NULL )updateGgWebGLTimeline( session, outputId, value = NULL, index = NULL, playing = NULL, speed = NULL, loop = NULL )
session |
A Shiny session object. |
outputId |
Output id passed to |
value |
Optional frame or time value to select. |
index |
Optional 1-based timeline index to select. Exactly one of
|
playing |
Optional logical scalar controlling playback. |
speed |
Optional positive playback-speed multiplier. |
loop |
Optional logical scalar controlling loop playback. |
NULL, invisibly.
if (interactive() && requireNamespace("shiny", quietly = TRUE)) { server <- function(input, output, session) { shiny::observeEvent(input$next_frame, { updateGgWebGLTimeline(session, "plot", index = 2) }) } }if (interactive() && requireNamespace("shiny", quietly = TRUE)) { server <- function(input, output, session) { shiny::observeEvent(input$next_frame, { updateGgWebGLTimeline(session, "plot", index = 2) }) } }
webgl_spec() creates a normalized renderer option list for
ggplot_webgl(), ggwebgl_spec(), and downstream adapter code. It is a
compact user-facing wrapper around the same internal normalization used by
theme_webgl().
webgl_spec( camera = c("panzoom", "orbit", "trackball"), projection = c("orthographic", "perspective"), dimension = NULL, depth_test = NULL, blend_mode = c("auto", "alpha", "additive", "premultiplied"), shader = NULL, interactions = NULL, view = NULL, selection = NULL, timeline = NULL, transport = NULL, ... )webgl_spec( camera = c("panzoom", "orbit", "trackball"), projection = c("orthographic", "perspective"), dimension = NULL, depth_test = NULL, blend_mode = c("auto", "alpha", "additive", "premultiplied"), shader = NULL, interactions = NULL, view = NULL, selection = NULL, timeline = NULL, transport = NULL, ... )
camera |
Camera/controller mode. |
projection |
Projection mode, |
dimension |
Optional renderer dimensionality. When omitted, |
depth_test |
Logical scalar. |
blend_mode |
Primitive blending mode: |
shader |
Optional shader preset. |
interactions |
Optional interaction mode vector. |
view |
Optional |
selection |
Optional |
timeline |
Optional |
transport |
Optional |
... |
Additional renderer options stored under |
A normalized renderer option list.
webgl_spec(camera = "orbit", projection = "perspective")webgl_spec(camera = "orbit", projection = "perspective")