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.
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_point() or
three_d.hide_point() as needed, before calling three_d.update_render() at the end.
show_point() and hide_point() functions because it can take some
time to do the rendering – it's more efficient to remove or add all the relevant points 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.