3D scatter plots in Lightning


Setup


In [1]:
import os
from lightning import Lightning

from numpy import random, asarray, amin, concatenate, column_stack 
from seaborn import color_palette
from sklearn import datasets

In [2]:
# replace with your own host and credentials, e.g. http://localhost:3000 or http://my-lightning-server.herokuapp.com
host = 'http://lightning-docs.herokuapp.com'
auth = (os.getenv('LIGHTNING_USERNAME'), os.getenv('LIGHTNING_PASSWORD'))

In [3]:
lgn = Lightning(ipython=True, host=host, auth=auth)
lgn.create_session('scatter3-ipython');


Random points with default styling


In [4]:
n = 100
x = random.rand(n)*100
y = random.rand(n)*100
z = random.rand(n)*100
lgn.scatter3(x,y,z)


Out[4]:


Random small red points


In [5]:
n = 100
x = random.rand(n)*100
y = random.rand(n)*100
z = random.rand(n)*100
c = [240,117,145]
lgn.scatter3(x,y,z,size=4,color=c)


Out[5]:


Random points with all styling options


In [6]:
n = 100
x = random.rand(n)*100
y = random.rand(n)*100
z = random.rand(n)*100
c = [asarray(color_palette('Blues', 100)[random.choice(range(100))])*255 for i in range(n)]
s = random.rand(n)*8+1
lgn.scatter3(x, y, z, color=c, size=s)


Out[6]:


Fun with colors


In [7]:
n = 500
x = random.rand(n)*255
y = random.rand(n)*255
z = random.rand(n)*255
c = column_stack((x,y,z))
lgn.scatter3(x,y,z,color=c, size=3)


Out[7]: