In [15]:
%matplotlib inline

In [16]:
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

# Use the GGPLOT style.
plt.style.use('ggplot')

In [17]:
for style in plt.style.available:
    print(style)


seaborn-deep
classic
seaborn-pastel
seaborn-darkgrid
ggplot
dark_background
grayscale
seaborn-whitegrid
seaborn-muted
seaborn-notebook
seaborn-dark-palette
seaborn-dark
seaborn-poster
seaborn-talk
fivethirtyeight
seaborn-bright
seaborn-ticks
seaborn-paper
seaborn-colorblind
bmh
seaborn-white

In [18]:
# Create our data and labels.
labels = ['Mystery', 'Sports', 'Science', 'Biography', 'History']
s = pd.Series([24, 15, 33, 18, 27], index=labels)

In [19]:
# Show our data as a table.
title = "Books Checked Out"
pd.DataFrame(s, columns=[title])


Out[19]:
Books Checked Out
Mystery 24
Sports 15
Science 33
Biography 18
History 27

In [20]:
# Show our data as a bar plot.
fig = plt.figure(figsize=(7,6))
ax = s.plot(kind='bar', rot=45)
result = ax.set_title(title)



In [35]:
# Show our data as a bar plot.
with plt.style.context('ggplot'):
    fig = plt.figure(figsize=(7,6))
    ax = s.plot(kind='barh')
    result = ax.set_title(title)



In [39]:
# Make a pie chart.
with plt.style.context('ggplot'):
    fig = plt.figure(figsize=(6,6))
    ax = plt.pie(s, labels=labels, autopct="%0.f%%", shadow=True)
    ax = plt.gca()
    o = ax.set_title(title)



In [41]:
# Student height data.
counts = [
    (3, 2),
    (7, 4),
    (5, 8),
    (6, 3),
    (4, 0),
]
labels = [43, 44, 45, 46, 47]
df = pd.DataFrame(counts, index=labels, columns=['Boys', 'Girls'])

In [42]:
# Show the data as a table.
df


Out[42]:
Boys Girls
43 3 2
44 7 4
45 5 8
46 6 3
47 4 0

In [44]:
# Plot boys and girls heights together ...
with plt.style.context('fivethirtyeight'):
    ax = df.plot(kind='bar', rot=0)
    o = ax.set_title("Student Heights")



In [46]:
# ... separately ...
# Plot boys and girls heights together ...
with plt.style.context('ggplot'):
    axes = df.plot(kind='bar', rot=0, subplots=True)
    for ax in axes:
        ax.legend().remove()



In [50]:
# ... and stacked.
# Plot boys and girls heights together ...
with plt.style.context('ggplot'):
    ax = df.plot(kind='bar', rot=0, stacked=True)
    o = ax.set_title("Student Heights")