Repository: vispy/vispy

Issue:
Need simple scene point cloud demo
So far only a complex grid-with-3-views example with 2D markers exist. I was certainly in the need of something simple like this and after a lot of digging and experimenting I reduced `magnify.py` to its minimum and added a third dimension to the markers.
I think this could serve well as an intro demo for the absolute beginner like me.
Let me know where should I point a pull request to or if I should wait until you guys have finished the MOAPR ;)

``` python
""" Demonstrates use of visual.Markers to create a point cloud with a
standard turntable camera to fly around with and a centered 3D Axis.
"""
import numpy as np
import vispy.scene
from vispy.scene import visuals

#
# Make a canvas and add simple view
#
canvas = vispy.scene.SceneCanvas(keys='interactive', show=True)
view = canvas.central_widget.add_view()


# generate data
centers = np.random.normal(size=(50, 3))
pos = np.random.normal(size=(100000, 3), scale=0.2)
indexes = np.random.normal(size=100000, loc=centers.shape[0]/2.,
                           scale=centers.shape[0]/3.)
indexes = np.clip(indexes, 0, centers.shape[0]-1).astype(int)
scales = 10**(np.linspace(-2, 0.5, centers.shape[0]))[indexes][:, np.newaxis]
pos *= scales
pos += centers[indexes]

# create scatter object and fill in the data
scatter = visuals.Markers()
scatter.set_data(pos, edge_color=None, face_color=(1, 1, 1, .5), size=5)
view.add(scatter)

view.camera = 'turntable'

axis = visuals.XYZAxis(parent=view.scene)

if __name__ == '__main__':
    import sys
    if sys.flags.interactive != 1:
        vispy.app.run()
```

Now let's see how hard it is to add a second marker set to this for moons and planets.. ;)



Discussion:
Cool! You can go ahead and make this into a PR against the current master; it won't conflict with any of the open PRs. The file should go in `examples/basics/scene`.

+1 from me, a PR into `master` should indeed be fine


Resolving patch:
diff --git a/examples/basics/scene/point_cloud.py b/examples/basics/scene/point_cloud.py
new file mode 100644
--- /dev/null
+++ b/examples/basics/scene/point_cloud.py
@@ -0,0 +1,47 @@
+# -*- coding: utf-8 -*-
+# vispy: gallery 10
+# Copyright (c) 2015, Vispy Development Team.
+# Distributed under the (new) BSD License. See LICENSE.txt for more info.
+
+""" Demonstrates use of visual.Markers to create a point cloud with a
+standard turntable camera to fly around with and a centered 3D Axis.
+"""
+
+import numpy as np
+import vispy.scene
+from vispy.scene import visuals
+
+#
+# Make a canvas and add simple view
+#
+canvas = vispy.scene.SceneCanvas(keys='interactive', show=True)
+view = canvas.central_widget.add_view()
+
+
+# generate data
+pos = np.random.normal(size=(100000, 3), scale=0.2)
+# one could stop here for the data generation, the rest is just to make the
+# data look more interesting. Copied over from magnify.py
+centers = np.random.normal(size=(50, 3))
+indexes = np.random.normal(size=100000, loc=centers.shape[0]/2.,
+                           scale=centers.shape[0]/3.)
+indexes = np.clip(indexes, 0, centers.shape[0]-1).astype(int)
+scales = 10**(np.linspace(-2, 0.5, centers.shape[0]))[indexes][:, np.newaxis]
+pos *= scales
+pos += centers[indexes]
+
+# create scatter object and fill in the data
+scatter = visuals.Markers()
+scatter.set_data(pos, edge_color=None, face_color=(1, 1, 1, .5), size=5)
+
+view.add(scatter)
+
+view.camera = 'turntable'  # or try 'arcball'
+
+# add a colored 3D axis for orientation
+axis = visuals.XYZAxis(parent=view.scene)
+
+if __name__ == '__main__':
+    import sys
+    if sys.flags.interactive != 1:
+        vispy.app.run()


Test patch: