The VizArray package provides a simple way of visualizing 2d NumPy arrays using the ipythonblocks library. The goal of VizArray is to help teach array based programming.
In [1]:
%matplotlib inline
import numpy as np
import vizarray
To visualize a NumPy array, just pass it to the vizarray.vizarray function:
In [2]:
a = np.random.rand(10,10)
In [3]:
vizarray.vizarray(a)
Out[3]:
If you call enable_notebook, vizarray will automatically be used as the default display method for all NumPy arrays:
In [4]:
vizarray.enable_notebook()
In [5]:
a
Out[5]:
Slicing works as expected:
In [6]:
a[0:2,0:2]
Out[6]:
In [7]:
a[0,:]
Out[7]:
In [8]:
a[:,0:2]
Out[8]:
You can set the colormap that is used with the set_cmap function, which accepts Matplotlib colormap names:
In [9]:
vizarray.set_cmap('Blues')
In [10]:
a
Out[10]:
In [11]:
t = np.linspace(0,2.0*np.pi,100)
In [12]:
t
Out[12]:
In [13]:
np.sin(t)
Out[13]:
You can set the block size in pixels (default is 30):
In [14]:
vizarray.set_block_size(10)
In [15]:
a
Out[15]:
The disable function will return NumPy arrays to their usual display format:
In [16]:
vizarray.disable_notebook()
In [17]:
a
Out[17]: