#coding: utf-8
%matplotlib inline
import numpy as np
import pandas as pd
from pandas import Series, DataFrame
import pylab as pl
import matplotlib.pyplot as plt
plt.style.use('ggplot')
ts = pd.Series(np.random.randn(1000), index=pd.date_range('1/1/2000', periods=1000))
ts = ts.cumsum()
ts.plot()
plt.plot(ts)
df = pd.DataFrame(np.random.randn(1000, 4), index=pd.date_range('1/1/2000', periods=1000), columns=list('ABCD'))
df = df.cumsum()
df.plot()
df.head()
# df['E'] = pd.Series(list(range(len(df))))
df['E'] = pd.Series(list(range(len(df))), index=df.index)
df.head()
df.plot(x='E', y='A')
rs = pd.Series(3 * np.random.rand(4), index=['a', 'b', 'c', 'd'], name='series')
rs.plot.pie(figsize=(6, 6))
df = pd.DataFrame(3 * np.random.rand(4, 2), index=['a', 'b', 'c', 'd'], columns=['x', 'y'])
df.plot.pie(subplots=True, figsize=(8, 4))
df = pd.DataFrame(np.random.rand(50, 4), columns=['a', 'b', 'c', 'd'])
df.plot.scatter(x='a', y='b')
ax = df.plot.scatter(x='a', y='b', color='DarkBlue', label='Group 1')
df.plot.scatter(x='c', y='d', color='DarkGreen', label='Group 2', ax=
df.plot.scatter(x='a', y='b', color='DarkBlue', label='Group 1'))
df.plot.scatter(x='a', y='b', c='c', s=50)
df.plot.scatter(x='a', y='b', s=df['c']*200)
df = pd.DataFrame(np.random.rand(10, 4), columns=['a', 'b', 'c', 'd'])
df.head()
df.ix[3].plot(kind='bar')
df.ix[3].plot.bar()
df.plot.bar()
df.plot.bar(stacked=True)
df.plot.barh(stacked=True)
df = pd.DataFrame({'a': np.random.randn(1000) + 1, 'b': np.random.randn(1000),
'c': np.random.randn(1000) - 1}, columns=['a', 'b', 'c'])
df.head()
df.plot.hist(alpha=0.5)
df.plot.hist(alpha=0.5, stacked=True)
df.plot.hist(alpha=0.5, stacked=True, bins=20)
df['a'].plot.hist(orientation='horizontal', cumulative=True)
df['a'].plot.hist(orientation='horizontal', cumulative=False)
df['a'].diff().hist()
df.diff().hist(color='k', alpha=0.5, bins=50)
data = pd.Series(np.random.randn(1000))
data.hist(by=np.random.randint(0, 4, 1000), figsize=(6, 4))