Plotting Module Examples


Timothy Helton

Imports


In [ ]:
import numpy as np
import pandas as pd

from k2datascience import plotting as k2plot

from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"
%matplotlib inline

Distribution Plot


In [ ]:
transaction_data = pd.Series(np.random.weibull(25, size=1000) * 100)
k2stats.distribution_plot(data=transaction_data,
                          title='E-Commerce Transaction Data',
                          x_label='US Dollars')

Pies Plot


In [ ]:
cities = {
    'Austin': ('TX', 93, 47),
    'Dallas': ('TX', 100, 39),
    'Denver': ('CO', 94, 43),
    'Portland': ('OR', 23, 9),
    'Raleigh': ('NC', 30, 24),
    'Seattle': ('WA', 353, 181),
}
cols = ['state', 'data_science', 'data_scientist']
data = pd.DataFrame([cities[x] for x in cities],
                    index=pd.Index(data=cities.keys(), name='City'),
                    columns=pd.Index(data=cols, name='Jobs'))
data.sort_index(inplace=True)
data['total'] = data[['data_science', 'data_scientist']].sum(axis=1)

In [ ]:
jobs = data[['data_science', 'data_scientist']]
k2stats.pies_plot(data=jobs, title='Job Distribution',
                  subtitle=('Data Science', 'Data Scientist'))