PrettyPlotLib

http://olgabot.github.io/prettyplotlib/

  • Package by Olga Botvinnik, a BioInformatics PhD student in San Diego
  • Focuses on prettifying matplotlib plots through customizing colors, transparencies, ticks & labels, etc.
  • Generally mirrors the standard matplotlib API
In [7]:
%run talktools
%matplotlib inline
In [8]:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import prettyplotlib as ppl

from prettyplotlib import brewer2mpl
In [9]:
fig, ax = plt.subplots(figsize=(8, 6))

for i in range(8):
    x = np.random.normal(loc=i, size=1000)
    y = np.random.normal(loc=i, size=1000)
    ppl.scatter(ax, x, y, label=str(i))

ppl.legend(ax);

And here's matplotlib for comparison

In [10]:
# Show the whole color range
fig, ax = plt.subplots(figsize=(8, 6))

for i in range(8):
    x = np.random.normal(loc=i, size=1000)
    y = np.random.normal(loc=i, size=1000)
    plt.scatter(x, y, label=str(i))

plt.legend();

Other plot types are available as well:

In [11]:
fig, ax = plt.subplots(figsize=(8, 6))

for i in range(8):
    y = np.random.normal(size=1000).cumsum()
    x = np.arange(1000)

    # For now, you need to specify both x and y :(
    # Still figuring out how to specify just one
    ppl.plot(ax, x, y, label=str(i), linewidth=0.75)

ppl.legend(ax);

Also some nice plot annotations with nice color selections:

In [12]:
import string

fig, ax = plt.subplots(figsize=(8, 6))
np.random.seed(14)
n = 10
ppl.bar(ax, np.arange(n), np.abs(np.random.randn(n)),
        annotate=range(n,2*n), grid='y', xticklabels=string.uppercase[:n])
Out[12]:
<Container object of 10 artists>