dplot3_xy: Interactive Scatter Plots

View source: R/dplot3_xy.R

dplot3_xyR Documentation

Interactive Scatter Plots

Description

Draw interactive scatter plots using plotly

Usage

dplot3_xy(
  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,
  formula = NULL,
  rsq = TRUE,
  mode = "markers",
  order.on.x = NULL,
  main = NULL,
  subtitle = NULL,
  xlab = NULL,
  ylab = NULL,
  col = NULL,
  alpha = NULL,
  theme = rtTheme,
  palette = rtPalette,
  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.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.alpha = 0.2,
  fit.params = list(),
  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,
  trace = 0,
  ...
)

Arguments

x

Numeric, vector/data.frame/list: x-axis data. If y is NULL and NCOL(x) > 1, first two columns used as x and y, respectively

y

Numeric, vector/data.frame/list: y-axis data

fit

Character: rtemis model to calculate y ~ x fit. Options: see select_learn() Can also be Logical, which will give a GAM fit if TRUE. If you specify "NLA", the activation function should be passed as a string.

se.fit

Logical: If TRUE, draw the standard error of the fit

se.times

Draw polygon or lines at +/- se.times * standard error of fit. Defaults to 1.96, which corresponds to 95 percent confidence interval

include.fit.name

Logical: If TRUE, include fit name in legend.

cluster

Character: Clusterer name. Will cluster data.frame(x, y) and pass result to group. Run select_clust for options

cluster.params

List: Names list of parameters to pass to the cluster function

group

Vector: Will be converted to factor; levels define group members. Default = NULL

formula

Formula: Provide a formula to be solved using s_NLS. If provided, fit is forced to 'nls'. e.g. y ~ b * m ^ x for a power curve. Note: nls is powerful but is prone to errors and warnings. Use single letters for parameter names, no numbers.

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 and y on x. Default = NULL, which becomes TRUE if mode includes lines.

main

Character: Main plot title.

subtitle

Character: Subtitle

xlab

Character: x-axis label.

ylab

Character: y-axis label.

col

Color for markers. Default=NULL, which will draw colors from palette

alpha

Float (0, 1]: Transparency for bar colors. Default = .8

theme

List or Character: Either the output of a ⁠theme_*()⁠ function or the name of a theme. Use themes() to get available theme names. Theme functions are of the form ⁠theme_<name>⁠.

palette

Character: Name of rtemis palette to use. Default = "rtCol1". Only used if col = NULL

axes.square

Logical: If TRUE: draw a square plot to fill the graphic device. Default = FALSE. Note: If TRUE, the device size at time of call is captured and height and width are set so as to draw the largest square available. This means that resizing the device window will not automatically resize the plot.

group.names

Character, vector, length = NROW(x): Group names. Default = NULL, which uses rownames(x)

font.size

Float: Font size for all labels. Default = 16

marker.col

Color for marker

marker.size

Numeric: Marker size.

symbol

Character: Marker symbol.

fit.col

Color: Color of the fit line.

fit.alpha

Float [0, 1]: Transparency for fit line

fit.lwd

Float: Fit line width

se.col

Color for se.fit

se.alpha

Alpha for se.fit

scatter.type

Character: "scatter", "scattergl", "scatter3d", "scatterternary", "scatterpolar", "scattermapbox",

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 whose distribution will be shown on x-axis. Only specify if different from x

marginal.y

Numeric: Data whose distribution will be shown on y-axis. Only specify if different from y

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. Default = NULL, which will be set to TRUE if there are more than 1 groups, or fit is set

legend.xy

Numeric, vector, length 2: x and y for plotly's legend

legend.xanchor

Character: Legend's x anchor: "left", "center", "right", "auto"

legend.yanchor

Character: Legend's y anchor: "top", "middle", "bottom", "auto"

legend.orientation

"v" or "h" for vertical or horizontal

legend.col

Color: Legend text color. Default = NULL, determined by theme

legend.bg

Color: Background color for legend

legend.border.col

Color: Border color for legend

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: "across", "toaxis", "marker", or any combination of those joined by +, e.g. "toaxis+across+marker"

spikesnap

Character: "data", "cursor", "hovered data"

spikecolor

Color for spikes

spikethickness

Numeric: Thickness of spikes

margin

Named list: plot margins.

main.y

Numeric: Y position of main title

main.yanchor

Character: "top", "middle", "bottom"

subtitle.x

Numeric: X position of subtitle relative to paper

subtitle.y

Numeric: Y position of subtitle relative to paper

subtitle.xref

Character: "paper", "x", "y"

subtitle.yref

Character: "paper", "x", "y"

subtitle.xanchor

Character: "left", "center", "right"

subtitle.yanchor

Character: "top", "middle", "bottom"

automargin.x

Logical: If TRUE, automatically set x-axis amrgins

automargin.y

Logical: If TRUE, automatically set y-axis amrgins

xlim

Float vector, length 2: x-axis limits

ylim

Float, vector, length 2: y-axis limits.

axes.equal

Logical: Should axes be equal? Defaults to FALSE

diagonal

Logical: If TRUE, draw diagonal line.

diagonal.col

Color: Color for diagonal.

diagonal.alpha

Float: Alpha for diagonal

fit.params

List: Arguments for learner defined by fit. Default = NULL, i.e. use default learner parameters

vline

Float, vector: If defined, draw a vertical line at this x value(s). Default = NULL

vline.col

Color for vline. Default = theme$fg

vline.width

Float: Width for vline. Default = 1

vline.dash

Character: Type of line to draw: "solid", "dot", "dash", "longdash", "dashdot", or "longdashdot"

hline

Float: If defined, draw a horizontal line at this y value.

hline.col

Color for hline. Default = "#ff0000" (red)

hline.width

Float: Width for hline. Default = 1

hline.dash

Character: Type of line to draw: "solid", "dot", "dash", "longdash", "dashdot", or "longdashdot"

hovertext

List of character vectors with hovertext to include for each group of markers

width

Numeric: Force plot size to this width. Default = NULL, i.e. fill available space

height

Numeric: Force plot size to this height. Default = NULL, i.e. fill available space

displayModeBar

Logical: If TRUE, show plotly's modebar

modeBar.file.format

Character: "svg", "png", "jpeg", "pdf" / any output file type supported by plotly and your system

scrollZoom

Logical: If TRUE, enable scroll zoom

filename

Character: Path to file to save static plot. Default = NULL

file.width

Integer: File width in pixels for when filename is set.

file.height

Integer: File height in pixels for when filename is set.

file.scale

Numeric: If saving to file, scale plot by this number

trace

Integer: The height the number the more diagnostic info is printed to the console

...

Additional arguments passed to theme

Details

use theme$tick.labels.col for both tick color and tick label color - this may change

Author(s)

E.D. Gennatas

Examples

## Not run: 
dplot3_xy(iris$Sepal.Length, iris$Petal.Length,
  fit = "gam", se.fit = TRUE, group = iris$Species
)

## End(Not run)


egenn/rtemis documentation built on Nov. 22, 2024, 4:12 a.m.