Draw interactive scatter plots using plotly
.
Usage
draw_scatter(
x,
y = NULL,
fit = NULL,
se_fit = FALSE,
se_times = 1.96,
include_fit_name = TRUE,
cluster = NULL,
cluster_params = list(k = 2),
group = NULL,
rsq = TRUE,
mode = "markers",
order_on_x = NULL,
main = NULL,
subtitle = NULL,
xlab = NULL,
ylab = NULL,
col = NULL,
alpha = NULL,
theme = rtemis_theme,
palette = rtemis_palette,
axes_square = FALSE,
group_names = NULL,
font_size = 16,
marker_col = NULL,
marker_size = 8,
symbol = "circle",
fit_col = NULL,
fit_alpha = 0.8,
fit_lwd = 2.5,
se_col = NULL,
se_alpha = 0.4,
scatter_type = "scatter",
show_marginal_x = FALSE,
show_marginal_y = FALSE,
marginal_x = x,
marginal_y = y,
marginal_x_y = NULL,
marginal_y_x = NULL,
marginal_col = NULL,
marginal_alpha = 0.333,
marginal_size = 10,
legend = NULL,
legend_title = NULL,
legend_trace = TRUE,
legend_xy = c(0, 0.98),
legend_xanchor = "left",
legend_yanchor = "auto",
legend_orientation = "v",
legend_col = NULL,
legend_bg = "#FFFFFF00",
legend_border_col = "#FFFFFF00",
legend_borderwidth = 0,
legend_group_gap = 0,
x_showspikes = FALSE,
y_showspikes = FALSE,
spikedash = "solid",
spikemode = "across",
spikesnap = "hovered data",
spikecolor = NULL,
spikethickness = 1,
margin = list(b = 65, l = 65, t = 50, r = 10, pad = 0),
main_y = 1,
main_yanchor = "bottom",
subtitle_x = 0.02,
subtitle_y = 0.99,
subtitle_xref = "paper",
subtitle_yref = "paper",
subtitle_xanchor = "left",
subtitle_yanchor = "top",
automargin_x = TRUE,
automargin_y = TRUE,
xlim = NULL,
ylim = NULL,
axes_equal = FALSE,
diagonal = FALSE,
diagonal_col = NULL,
diagonal_dash = "dot",
diagonal_alpha = 0.66,
fit_params = NULL,
vline = NULL,
vline_col = theme[["fg"]],
vline_width = 1,
vline_dash = "dot",
hline = NULL,
hline_col = theme[["fg"]],
hline_width = 1,
hline_dash = "dot",
hovertext = NULL,
width = NULL,
height = NULL,
displayModeBar = TRUE,
modeBar_file_format = "svg",
scrollZoom = TRUE,
filename = NULL,
file_width = 500,
file_height = 500,
file_scale = 1,
verbosity = 0L,
...
)
Arguments
- x
Numeric, vector/data.frame/list: x-axis data. If y is NULL and
NCOL(x) > 1
, first two columns used asx
andy
, respectively.- y
Numeric, vector/data.frame/list: y-axis data.
- fit
Character: Fit method.
- se_fit
Logical: If TRUE, include standard error of the fit.
- se_times
Numeric: Multiplier for standard error.
- include_fit_name
Logical: If TRUE, include fit name in legend.
- cluster
Character: Clustering method.
- cluster_params
List: Parameters for clustering.
- group
Factor: Grouping variable.
- rsq
Logical: If TRUE, print R-squared values in legend if
fit
is set.- mode
Character, vector: "markers", "lines", "markers+lines".
- order_on_x
Logical: If TRUE, order
x
andy
onx
.- main
Character: Main title.
- subtitle
Character: Subtitle.
- xlab
Character: x-axis label.
- ylab
Character: y-axis label.
- col
Color for markers.
- alpha
Numeric: Alpha for markers.
- theme
List: Plot theme.
- palette
Character: Color palette.
- axes_square
Logical: If TRUE, draw a square plot.
- group_names
Character: Names for groups.
- font_size
Numeric: Font size.
- marker_col
Color for markers.
- marker_size
Numeric: Marker size.
- symbol
Character: Marker symbol.
- fit_col
Color for fit line.
- fit_alpha
Numeric: Alpha for fit line.
- fit_lwd
Numeric: Line width for fit line.
- se_col
Color for standard error band.
- se_alpha
Numeric: Alpha for standard error band.
- scatter_type
Character: Scatter plot type.
- show_marginal_x
Logical: If TRUE, add marginal distribution line markers on x-axis.
- show_marginal_y
Logical: If TRUE, add marginal distribution line markers on y-axis.
- marginal_x
Numeric: Data for marginal distribution on x-axis.
- marginal_y
Numeric: Data for marginal distribution on y-axis.
- marginal_x_y
Numeric: Y position of marginal markers on x-axis.
- marginal_y_x
Numeric: X position of marginal markers on y-axis.
- marginal_col
Color for marginal markers.
- marginal_alpha
Numeric: Alpha for marginal markers.
- marginal_size
Numeric: Size of marginal markers.
- legend
Logical: If TRUE, draw legend.
- legend_title
Character: Title for legend.
- legend_trace
Logical: If TRUE, draw legend trace. (For when you have
fit
and don't want a trace for the markers.)- legend_xy
Numeric: Position of legend.
- legend_xanchor
Character: X anchor for legend.
- legend_yanchor
Character: Y anchor for legend.
- legend_orientation
Character: Orientation of legend.
- legend_col
Color for legend text.
- legend_bg
Color for legend background.
- legend_border_col
Color for legend border.
- legend_borderwidth
Numeric: Border width for legend.
- legend_group_gap
Numeric: Gap between legend groups.
- x_showspikes
Logical: If TRUE, show spikes on x-axis.
- y_showspikes
Logical: If TRUE, show spikes on y-axis.
- spikedash
Character: Dash type for spikes.
- spikemode
Character: Spike mode.
- spikesnap
Character: Spike snap mode.
- spikecolor
Color for spikes.
- spikethickness
Numeric: Thickness of spikes.
- margin
List: Plot margins.
- main_y
Numeric: Y position of main title.
- main_yanchor
Character: Y anchor for main title.
- subtitle_x
Numeric: X position of subtitle.
- subtitle_y
Numeric: Y position of subtitle.
- subtitle_xref
Character: X reference for subtitle.
- subtitle_yref
Character: Y reference for subtitle.
- subtitle_xanchor
Character: X anchor for subtitle.
- subtitle_yanchor
Character: Y anchor for subtitle.
- automargin_x
Logical: If TRUE, automatically adjust x-axis margins.
- automargin_y
Logical: If TRUE, automatically adjust y-axis margins.
- xlim
Numeric: Limits for x-axis.
- ylim
Numeric: Limits for y-axis.
- axes_equal
Logical: If TRUE, set equal scaling for axes.
- diagonal
Logical: If TRUE, add diagonal line.
- diagonal_col
Color for diagonal line.
- diagonal_dash
Character: "solid", "dash", "dot", "dashdot", "longdash", "longdashdot". Dash type for diagonal line.
- diagonal_alpha
Numeric: Alpha for diagonal line.
- fit_params
Hyperparameters: Parameters for fit.
- vline
Numeric: X position for vertical line.
- vline_col
Color for vertical line.
- vline_width
Numeric: Width for vertical line.
- vline_dash
Character: Dash type for vertical line.
- hline
Numeric: Y position for horizontal line.
- hline_col
Color for horizontal line.
- hline_width
Numeric: Width for horizontal line.
- hline_dash
Character: Dash type for horizontal line.
- hovertext
List: Hover text for markers.
- width
Numeric: Width of plot.
- height
Numeric: Height of plot.
- displayModeBar
Logical: If TRUE, display mode bar.
- modeBar_file_format
Character: File format for mode bar.
- scrollZoom
Logical: If TRUE, enable scroll zoom.
- filename
Character: Filename to save plot.
- file_width
Numeric: Width of saved file.
- file_height
Numeric: Height of saved file.
- file_scale
Numeric: Scale of saved file.
- verbosity
Integer: Verbosity level.
- ...
Additional arguments passed to the theme function.