legend3js {r3js} | R Documentation |
Add a legend to an data3js object
Description
Add a legend to an data3js object
Usage
legend3js(data3js, legend, fill)
Arguments
data3js |
The data3js object |
legend |
Character vector of legend labels |
fill |
If supplied the fill color of a box placed next to each label |
Value
Returns an updated data3js object
See Also
Other plot components:
arrows3js()
,
axis3js()
,
box3js()
,
grid3js()
,
light3js()
,
lines3js()
,
mtext3js()
,
points3js()
,
segments3js()
,
shape3js()
,
sphere3js()
,
surface3js()
,
text3js()
,
triangle3js()
Examples
# Setup plot
p <- plot3js(
x = iris$Sepal.Length,
y = iris$Sepal.Width,
z = iris$Petal.Length,
col = rainbow(3)[iris$Species],
xlab = "Sepal Length",
ylab = "Sepal Width",
zlab = "Petal Length"
)
# Add simple legend
p <- legend3js(
data3js = p,
legend = levels(iris$Species),
fill = rainbow(3)
)
# View plot
r3js(p, zoom = 2)
[Package r3js version 0.0.2 Index]