The plot below shows three variables from the Iris dataset.
Mouse controls: Left-click and drag to rotate; alt (Mac)- or ctrl (Windows)-click-drag or middle-click-drag to pan; scroll or shift-click-drag to zoom. Touch screen controls: one finger to rotate; two-finger scroll to pan; pinch to zoom.
Toggle setosa, versicolor, virginica.
You can see how the plot is constructed in the HTML source:
params.groups
.
three_d.plots[0]
to store if its points are currently being displayed.
toggle_species()
function reads the flags, and calls either three_d.show_group()
or
three_d.hide_group()
as needed, before calling three_d.update_render()
at the end.
show_group()
and hide_group()
functions because it can take some
time to do the rendering – here there is only one action to perform, but in general you might want to make many changes to a plot, and it's more
efficient to make all of these changes and then only re-render once.
The Iris dataset is included with R; the R script I used to turn it into JavaScript is here; the code sources my main JS-writing function write_three_d.R.
Posted 2016-10-02, updated 2016-12-22 (v1; groups).