easy_plot_ly: Easy Plotting with Plotly

Description Usage Arguments Value Examples

View source: R/easy_plot_ly.R

Description

This function provides a simple way to generate 2D and 3D plots using the R package plotly.

Usage

1
2
3
4
5
6
7
## x, y, z, and color variables need to be in a vectorized form like x$data or y$data.
## If you are using the surface plot type, a z variable matrix is all that should be used,
## if non matrix data is put into the funciton for x and y they will be converted to a z matrix
## Line plots should use quantitative color variables. 3D density plots require only an x and y variable
## and will create a z matrix for you

easy_plot_ly(x, y, z, color, type, data)

Arguments

x

The x-axis variable

y

The y-axis variable

z

The z-axis variable

color

A cateogrical or quantitative variable to subset the data

type

The type of plot you would like to generate: "scatter", "line", "surface", "3d_density", "mesh", or "auto" to have plotly generate one for you

data

The datset that will be used

Value

A 2D or 3D plot based on the package plotly

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
           Scatter Plot:
easy_plot_ly(x = iris$Sepal.Length, y = iris$Sepal.Width, z = iris$Petal.Length,
             color = iris$Species, type = 'scatter', data = iris)


           Line Plot:
df1 <- data.frame(x = sin(1:1000), y = cos(1:1000), z = 1:1000)
easy_plot_ly(x = df1$x, y = df1$y, z = df1$z, color = df1$x, type = 'line', data = df1)


           Surface Plot:
easy_plot_ly(z = volcano, type = 'surface', data = volcano)


           3D Density Plot:
easy_plot_ly(x = iris$Sepal.Length, y = iris$Sepal.Width, type = '3d_density', data = iris)


           Mesh Plot:
easy_plot_ly(x = iris$Sepal.Length, y = iris$Sepal.Width, z = iris$Petal.Length,
             type = 'mesh', data = iris)

shanealman/EZRplots documentation built on May 13, 2020, 3:29 a.m.