Advanced Alternative Visualizations

Starting with bqplot, and ending with ipyvolume.


In [1]:
import matplotlib.pyplot as plt

import seaborn as sns
sns.set_context('poster')
sns.set_style('whitegrid') 
# sns.set_style('darkgrid') 
plt.rcParams['figure.figsize'] = 12, 8  # plotsize 

import numpy as np
import pandas as pd
from pandas.plotting import scatter_matrix
from sklearn.datasets import load_boston

import warnings
warnings.filterwarnings('ignore')

import matplotlib as mpl

In [2]:
from IPython.display import YouTubeVideo

BQPlot

Examples here are shamelessly stolen from the amazing: https://github.com/maartenbreddels/jupytercon-2017/blob/master/jupytercon2017-widgets.ipynb


In [3]:
# mixed feelings about this import
import bqplot.pyplot as plt
import numpy as np

In [4]:
YouTubeVideo("uHPcshgTotE", width=560, height=315)


Out[4]:

In [5]:
x = np.linspace(0, 2, 50)
y = x**2

In [6]:
fig = plt.figure()
scatter = plt.scatter(x, y)
plt.show()



In [8]:
fig.animation_duration = 500
scatter.y = x**2.5

In [9]:
scatter.selected_style = {'stroke':'red', 'fill': 'orange'}
plt.brush_selector();

In [10]:
scatter.selected


Out[10]:
array([16, 17, 18, 19, 20, 21, 22, 23], dtype=uint32)

In [11]:
scatter.selected = [1,2,10,42,45]

ipyvolume


In [12]:
import ipyvolume as ipv

In [13]:
N = 1000
x, y, z = np.random.random((3, N))

In [20]:
fig = ipv.figure()
scatter = ipv.scatter(x, y, z, marker='box')
ipv.show()



In [19]:
scatter.x = x + np.random.rand() - 0.5

In [21]:
scatter.color = "green"
scatter.size = 5

In [22]:
scatter.color = np.random.random((N,3))

In [23]:
scatter.size = 2

In [24]:
ex = ipv.datasets.animated_stream.fetch().data

In [25]:
ex.shape


Out[25]:
(6, 200, 1250)

In [26]:
ex[:, ::, ::4].shape


Out[26]:
(6, 200, 313)

In [27]:
ipv.figure()
ipv.style.use('dark')
quiver = ipv.quiver(*ipv.datasets.animated_stream.fetch().data[:,::,::4], size=5)
ipv.animation_control(quiver, interval=200)
ipv.show()
ipv.style.use('light')



In [28]:
quiver.geo = "cat"

In [29]:
N = 1000*1000

x, y, z = np.random.random((3, N)).astype('f4')

In [30]:
ipv.figure()
s = ipv.scatter(x, y, z, size=0.2, )
ipv.show()



In [31]:
ipv.save("3d-example-plot.html")

In [32]:
!open 3d-example-plot.html

In [ ]: