This is an example notebook for the `prettyplotlib` plotting library. It is still under construction, so any feedback is welcome!

• Contact: obotvinn@ucsd.edu
• Author: Olga Botvinnik

New syntax: Don't need to supply `ax` everywhere!

For those of you using `ppl.remove_chartjunk`, your code is now broken. Get it now via `from prettyplotlib.utils import remove_chartjunk`

## Scatter

``````

In [1]:

import prettyplotlib as ppl

# Set the random seed for consistency
np.random.seed(12)

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

ppl.legend(ax)
ax.set_title('prettyplotlib `scatter`')

``````
``````

Out[1]:

``````

## Plot

``````

In [1]:

``````
``````

``````
``````

In [5]:

import prettyplotlib as ppl

# Set the random seed for consistency
np.random.seed(12)

# Show the whole color range
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(x, y, label=str(i), linewidth=0.75)

ppl.legend()

``````
``````

Out[5]:

<matplotlib.legend.Legend at 0x107a0b090>

``````

## `fill_between`

``````

In [2]:

import prettyplotlib as ppl

# Set the random seed for consistency
np.random.seed(12)

# Show the whole color range
for i in range(8):
y1 = np.random.normal(size=1000).cumsum()
y2 = np.random.normal(size=1000).cumsum()
x = np.arange(1000)

ppl.fill_between(x, y1, y2, label=str(i))

ppl.legend()

``````
``````

``````

## `fill_betweenx`

``````

In [4]:

import prettyplotlib as ppl

# Set the random seed for consistency
np.random.seed(12)

# Show the whole color range
for i in range(8):
y1 = np.random.normal(size=1000).cumsum()
y2 = np.random.normal(size=1000).cumsum()
x = np.arange(1000)
ppl.fill_betweenx(x, y1, y2, label=str(i))

ppl.legend()

``````
``````

``````

## `pcolormesh`

Save the `fig` object that's returned because otherwise you see two of the same plot.

``````

In [3]:

import prettyplotlib as ppl
from prettyplotlib import brewer2mpl
import numpy as np
import string

green_purple = brewer2mpl.get_map('PRGn', 'diverging', 11).mpl_colormap

np.random.seed(10)

fig = ppl.pcolormesh(np.random.randn(10,10),
xticklabels=string.uppercase[:10],
yticklabels=string.lowercase[-10:],
cmap=green_purple)

``````
``````

``````

### `pcolormesh`: recenter the "0" value via `center_value`

``````fig = ppl.pcolormesh(np.random.randn(10,10),
xticklabels=string.uppercase[:10],
yticklabels=string.lowercase[-10:],
cmap=green_purple,
center_value=2)``````
``````

In [4]:

import prettyplotlib as ppl
from prettyplotlib import brewer2mpl
import numpy as np
import string

green_purple = brewer2mpl.get_map('PRGn', 'diverging', 11).mpl_colormap

np.random.seed(10)

fig = ppl.pcolormesh(np.random.randn(10,10),
xticklabels=string.uppercase[:10],
yticklabels=string.lowercase[-10:],
cmap=green_purple,
center_value=2)

``````
``````

``````

# `hist`

``````

In [12]:

import prettyplotlib as ppl
import matplotlib.pyplot as plt
import numpy as np

np.random.seed(12)

# 'y' for the 'y' axis. Could also add a grid over the 'x' axis.
ppl.hist(np.random.randn(1000), grid='y')

``````
``````

Out[12]:

<matplotlib.axes.AxesSubplot at 0x10b71b050>

``````

# `bar`

``````

In [13]:

import prettyplotlib as ppl
import numpy as np
import string

np.random.seed(14)
n = 10
ppl.bar(np.arange(n), np.abs(np.random.randn(n)), annotate=True, grid='y')

``````
``````

Out[13]:

<Container object of 10 artists>

``````

# `barh`

``````

In [17]:

import prettyplotlib as ppl
import numpy as np
import string

np.random.seed(14)
n = 10
ppl.barh(np.arange(n), np.abs(np.random.randn(n)), annotate=True, grid='y')

``````
``````

Out[17]:

<matplotlib.axes.AxesSubplot at 0x10b780650>

``````

# `boxplot`

``````

In [8]:

import prettyplotlib as ppl
import matplotlib as mpl

np.random.seed(10)

data = np.random.randn(8, 4)
labels = ['A', 'B', 'C', 'D']

ppl.boxplot(data, xticklabels=labels)

``````
``````

Out[8]:

<matplotlib.axes.AxesSubplot at 0x10b46e050>

``````
``````

In [ ]:

``````