Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
3D Scatter demo with Plotrb
require 'plotrb'
values = []
for x in -5..5
for z in -5..5
values.push({x: x, y: (x*x+z*z)/5, z: z})
end
end
data = pdata.name('data').values(values)
mark = rect_mark.from(data)
vis = visualization.width(500).height(500) do
padding top: 10, left: 30, bottom: 30, right: 10
data data
marks mark
enable :Plot3D
end
vis.output_server("3D_scatter")

3D Scatter demo with Plotrb

alt text

Plotrb render 3D scatter like above (rendered function: y=x*x+z*z).
You can rotate and zoom it with your mouse.
My work is based on hlvoorhees's scatter plot demo. (gist here)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment