points3d: Add points to a 3D scatterplot

Description Usage Arguments Value Note Examples

View source: R/scatterplot.R

Description

Add points to a 3D scatterplot

Usage

1
points3d(s, x, y, z, color = "orange", pch = "@", size = 1, labels = "")

Arguments

s

A non-animated scatterplot object returned by scatterplot3js.

x

Either a vector of x-coordinate values or a three-column data matrix with columns corresponding to the x,y,z coordinate axes. Column labels, if present, are used as axis labels.

y

(Optional) vector of y-coordinate values, not required if x is a matrix.

z

(Optional) vector of z-coordinate values, not required if x is a matrix.

color

Either a single hex or named color name (all points same color), or a vector of hex or named color names as long as the number of data points to plot.

pch

Optional point glyphs or text strings, see scatterplot3js.

size

The plot point radius, either as a single number or a vector of sizes of length nrow(x).

labels

Character vector of length x of point labels displayed when the mouse moves over the points.

Value

A new scatterplot htmlwidget object.

Note

This function replaces the old points3d approach used by scatterplot3d.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Not run: 
 # Adding point labels to a scatterplot:
 x <- rnorm(5)
 y <- rnorm(5)
 z <- rnorm(5)
 scatterplot3js(x, y, z, pch="o") %>%
   points3d(x + 0.1, y + 0.1, z, color="red", pch=paste("point", 1:5))

# Adding point labels to a graph, obtaining the graph vertex coordinates
# with the `vertices()` function:
data(LeMis)
graphjs(LeMis) %>% points3d(vertices(.), color="red", pch=V(LeMis)$label)


## End(Not run)

Example output

Loading required package: igraph

Attaching package: 'igraph'

The following objects are masked from 'package:stats':

    decompose, spectrum

The following object is masked from 'package:base':

    union

threejs documentation built on Aug. 13, 2017, 9:06 a.m.