This is one of the 100 recipes of the IPython Cookbook, the definitive guide to high-performance scientific computing and data science in Python.
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
plt.figure(figsize=(6,4));
np.random.seed(12)
for i in range(8):
x = np.arange(1000)
y = np.random.randn(1000).cumsum()
plt.plot(x, y, label=str(i))
plt.legend();
matplotlib.pyplot
namespace with prettyplotlib
.import prettyplotlib as ppl
plt.figure(figsize=(6,4));
np.random.seed(12)
for i in range(8):
x = np.arange(1000)
y = np.random.randn(1000).cumsum()
ppl.plot(x, y, label=str(i))
ppl.legend();
The figure appears clearer, and the colors are more visually pleasant.
pcolormesh
function to display a 2D array as an image.plt.figure(figsize=(4,3));
np.random.seed(12)
plt.pcolormesh(np.random.rand(16, 16));
plt.colorbar();
The default rainbow color map is known to mislead data visualization.
plt.figure(figsize=(4,3));
np.random.seed(12);
ppl.pcolormesh(np.random.rand(16, 16));
<matplotlib.figure.Figure at 0x76efe80>
This visualization is much clearer, in that high or low values are better brought out than with the rainbow color map.
You'll find all the explanations, figures, references, and much more in the book (to be released later this summer).
IPython Cookbook, by Cyrille Rossant, Packt Publishing, 2014 (500 pages).