Plotly R Cheat Sheet

ADVERTISEMENT

plot_ly
(
set.seed(
123
)
plot_ly
(
set.seed(
123
)
x
= c( 1, 2,
3
),
x
=
1
:
100
x
= c( 1, 2,
3
),
x
=
1
:
100
y
= c( 5, 6,
7
),
y1
=
2*x
+ rnorm(
100
)
y
= c( 5, 6, 7),
y1
=
2*x
+
rnorm
(
100
)
type
=
‘scatter’
,
y2
=
-2*x
+ rnorm(
100
)
type
=
‘scatter’
,
y2
=
-2*x
+
rnorm
(
100
)
mode
=
‘markers’
,
mode
=
‘lines’
)
size
= c( 1, 5,
10
),
axis_template
<- list(
plot_ly
(
marker
= list(
showgrid
=
F
,
x
=
x
,
color
= c( ‘red’,
‘blue’
,
zeroline
=
F
,
y
=
y1
,
‘green’
)))
nticks
=
20
,
type
=
‘scatter’
) %>%
showline
=
T
,
title
=
‘AXIS’
,
add_trace(
mirror
=
‘all’
)
x
=
x
,
y
=
y2
) %>%
plot_ly
(
plot.ly/r/getting-started
plot_ly
(
x
= c( 1, 2,
3
),
x
=
x
,
layout(
y
= c( 5, 6,
7
),
y
=
y1
,
legend
=
type
=
‘scatter’
,
type
=
‘scatter’
) %>%
list(
x
=
0.5
,
mode
=
‘markers’
)
y
=
1
,
layout(
bgcolor
=
‘#F3F3F3’
))
xaxis
=
axis_template
,
yaxis
=
axis_template
)
library(
plotly
)
p
<-
plot_ly
(
x
= rnorm(
1000
),
y
= rnorm(
1000
),
mode
=
‘markers’
)
plot_ly
(
plot_ly
(
x
= c( 1, 2, 3),
x
= c( 1, 2,
3
),
y
= c( 5, 6, 7),
y
= c( 5, 6,
7
),
type
=
‘bar’
,
type
=
‘scatter’
,
mode
=
‘markers’
)
mode
=
‘lines’
,
fill
=
‘tozeroy’
)

ADVERTISEMENT

00 votes

Related Articles

Related forms

Related Categories

Parent category: Education
Go
Page of 2