Draw interactive three-dimensional points with optional highlights.
Usage
plot_scatter3d(
data,
x = "x",
y = "y",
z = "z",
text = NULL,
color = NULL,
colors = NULL,
marker = list(size = 1.5),
name = NULL,
highlight = NULL,
highlight_text = NULL,
highlight_marker = list(size = 2, color = "black", symbol = "circle-open"),
title = NULL,
xlab = x,
ylab = y,
zlab = z,
legend = list(),
font = NULL,
width = NULL,
height = NULL
)Arguments
- data
A data frame containing numeric coordinate columns.
- x, y, z
Single column names for the three coordinates. Defaults are
"x","y", and"z".- text
Optional hover text for the observations.
- color
Optional values passed to Plotly's categorical colour mapping.
- colors
Optional colours for that mapping.
- marker
A Plotly marker list. Default
list(size = 1.5). Continuous colours and their colourbar can be supplied through this list.- name
Optional name of the main trace.
- highlight
An optional data frame with the same coordinate columns. A non-NULL, zero-row data frame still creates a highlight trace.
- highlight_text
Optional hover text for highlighted observations.
- highlight_marker
A Plotly marker list for highlights. The default uses black open circles of size
2.- title
A Plotly title string or title list. Default
NULL.- xlab, ylab, zlab
Axis titles. Defaults are the coordinate column names.
- legend
A Plotly legend list. Default
list().- font
An optional Plotly font list. Default
NULL.- width, height
Optional widget dimensions in pixels.
Value
A Plotly htmlwidget. Add traces with plotly::add_trace() or change
its layout with plotly::layout().
Examples
points <- data.frame(
x = c(0, 1, 2, 0, 1, 2),
y = c(0, 0.5, 0, 1, 1.5, 1),
z = c(0, 0.5, 1, 1.5, 2, 2.5),
group = factor(rep(c("A", "B"), each = 3)),
value = seq_len(6)
)
plot_scatter3d(
points,
color = points$group,
colors = palette_colors(x = c("A", "B"), palette = "Chinese")
)
plot_scatter3d(
points,
marker = list(color = points$value, size = 3, showscale = TRUE),
highlight = points[c(1, 5), ],
title = "Continuous values with highlighted observations"
)