Make scatterplots with plot_ly()
Usage
interactive_scatterplot(
x,
y,
z = NULL,
colorby = NULL,
plot_type = "scatter",
title = "",
legend_title = "",
xlab = "x",
ylab = "y",
zlab = "z",
palette = NULL,
point_size = 5,
labels = NULL,
show_labels = FALSE,
lines = NULL,
hline_thresholds = NULL,
vline_thresholds = NULL,
xrange = NULL,
yrange = NULL,
showlegend = TRUE,
palette_name = COLORBLIND_PALETTE_NAME,
colorby_menu = NULL
)Arguments
- x
X coordinates
- y
Y coordinates
- z
Optional Z coordinates
- colorby
String vector or factor specifying value groups
- plot_type
Plot type: 'scatter' or 'scatter3d'
- title
Plot title
- legend_title
Legend title
- xlab
X label
- ylab
Y label
- zlab
Z label
- palette
Color palette correct for the number of groups in 'colorby'
- point_size
Main point size
- labels
Point labels
- show_labels
Permanently show labels for labelled points (default is just on hoverover). Ignored when
colorby_menuis supplied.- lines
3 column data-frame (name, x, y) with two rows, one for the start and end of each named line
- hline_thresholds
Named list of horizontal lines with y coordinates
- vline_thresholds
Named list of vertical lines x coordinates
- xrange
Optional fixed c(min, max) x axis range, e.g. to keep a volcano plot symmetric around zero. Only applied when lines/thresholds are drawn; otherwise plotly's own autorange is used. Defaults to NULL (derive the range from the data).
- yrange
Optional fixed c(min, max) y axis range. Same caveats as
xrange.- showlegend
Boolean: show a legend?
- palette_name
Valid R color palette name
Opt-in, named list of alternative colour vectors (one per entry, same length as x/y(/z)). When supplied, the plot is coloured using
addColorbyMenuinstead ofcolorby, and a plotly dropdown is added letting the reader switch which variable colours the points;colorbyis not shown itself unless also included as an entry incolorby_menu. This is intended for standalone/static-HTML report use only: the Shiny scatterplot modules already offer their own colour-byselectInput, and must NOT set this argument, since an always-on in-widget dropdown alongside that control would give readers two competing ways to change the colouring. Default is NULL (off).
