legend3js.Rd
Add a legend to an data3js object
legend3js(data3js, legend, fill)
The data3js object
Character vector of legend labels
If supplied the fill color of a box placed next to each label
Returns an updated data3js object
Other plot components:
arrows3js()
,
axis3js()
,
box3js()
,
grid3js()
,
light3js()
,
lines3js()
,
mtext3js()
,
points3js()
,
segments3js()
,
shape3js()
,
sphere3js()
,
surface3js()
,
text3js()
,
triangle3js()
# 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)