scatterplotly: scatterplotly

Description Usage Arguments Details Value Note Author(s) See Also Examples

Description

Create scatterplots using plotly's R API. Type scatterplotly() for visual help.

Usage

1
2
3
4
5
6
7
scatterplotly(x, y, xlab = NULL, ylab = NULL, theme, groupcolor, groupsize,
  groupsymbol, title = "", subtitle = "", title.size = 30,
  title.fontface = "Times New Roman", description = "", desc.x = 0.7,
  desc.y = 0.2, desc.size = 12, desc.fontface = "arial", markersize = 5,
  markeropacity = 0.8, markertype = "circle", markerlinewidth = 1,
  markerlinecolor = "black", width = NULL, height = NULL,
  xaxis.range = NULL, yaxis.range = NULL, legendorientation = "v", ...)

Arguments

x

A vector of x-coordinates

y

A vector of y-coordinates

xlab

x-axis label (optional)

ylab

y-axis label (optional)

theme

color theme (see details below)

groupcolor

a vector specifying group level color mapping

groupsize

a vector specifying group level size mapping

groupsymbol

a vector specifying group level marker-type mapping

title

Chart title

subtitle

Chart subtitle (optional)

title.size

Chart title size (default: 30)

title.fontface

Chart title (and subtitle) font family(default: Times New Roman)

description

Character vector to specify additional description (optional)

desc.x

Description annotation's x position (default: 0.7)

desc.y

Description annotation's y position (default: 0.2)

desc.size

Description annotation's font size (default: 12)

desc.fontface

Description annotation's font family (default: arial)

markersize

Point size (in px) (default: 5)

markeropacity

Point alpha (0 1) (default: 1)

markertype

Point style (default: circle)

markerlinewidth

Width of line around point (default: 1)

markerlinecolor

Color of line around point (default: Black)

width

Canvas width (default: 800)

height

Canvas height (default: 600)

xaxis.range

xaxis limits (a numeric vector of size two specifying lower and upper limits)

yaxis.range

yaxis limits (a numeric vector of size two specifying lower and upper limits)

legendorientation

specify the location of the legend ("v" or "h)

...

Other arguments that can be passed to plot_ly()

Details

Internally, plot_ly() is used to generate all plots. All of the above arguments are mapped to specific arguments to plot_ly(). The function assigns default values to many plot_ly() arguments like marker-size, marker-opacity etc. to allow for an easier interface.

Type plotlyvis::scatterplotly to see the source code. Alternatively you can press F2 if using R-Studio.

Currently, four color themes are built in: BLUE, YELLOW, LIGHTGRAY and DARKGRAY.

Value

Returns a plotly built object. Use $ for further manipulations and edits.

Note

The title, subtitle and description are added as annotations. By default the xref and yref arguments are set to paper. See plotly - annotations for more details.

Author(s)

Riddhiman Roy

See Also

plot_ly plotly_build

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
library(plotlyvis)

# Simple scatter plot
scatterplotly(x = rnorm(1000), y = rnorm(1000), title = "Simple scatter plot")

# Group level mappings
n = 500
x = seq(-1, 1, length.out = n)
y = round(2 * x^2 + rnorm(n, sd = 0.25),2)
size = c(1:250, 250:1)
color = sample(LETTERS[1:4], size = n, replace = TRUE)
symbol = sample(letters[1:3], size = n, replace = TRUE)
scatterplotly(x = x, y = y,
              groupcolor = color,
              groupsize = size,
              groupsymbol = symbol,
              title = "Advanced scatterplot",
              subtitle = "Scatterplot with group level color, size and symbol mappings")

#Theme
scatterplotly(x = rnorm(1000), y = rnorm(1000), title = "Simple scatter plot", theme = "BLUE")

royr2/plotlyvis documentation built on May 27, 2019, 11:47 p.m.