Skip to content

Commit 4a5dc37

Browse files
committed
notebooks; demo
1 parent 01c5520 commit 4a5dc37

File tree

3 files changed

+70
-2
lines changed

3 files changed

+70
-2
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ that allow users to quickly and easily make good looking plots. So say good-bye
88
to matplotlib, and hello to ggplot as your everyday Python plotting library!
99

1010
# Outline
11-
## Intro
11+
## Slides (20 mins)
12+
### Intro
1213
#### Me
1314
- Hi, I'm Greg!
1415
#### What is `ggplot`?
@@ -20,7 +21,8 @@ to matplotlib, and hello to ggplot as your everyday Python plotting library!
2021
#### Where it's going
2122
- things that don't exist yet
2223

23-
## Tutorial
24+
## IPython Notebook (40-50 mins)
25+
### Tutorial
2426
#### `aesthetics`
2527
- assigning `x` and `y`
2628
#### components

faceting.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import matplotlib.pyplot as plt
2+
import pandas as pd
3+
import numpy as np
4+
5+
N = 100
6+
industry = ['a','b','c']
7+
city = ['x','y','z']
8+
ind = np.random.choice(industry, N)
9+
cty = np.random.choice(city, N)
10+
jobs = np.random.randint(low=1,high=250,size=N)
11+
df_city =pd.DataFrame({'industry':ind,'city':cty,'jobs':jobs})
12+
13+
## how many panels do we need?
14+
cols =df_city.city.value_counts().shape[0]
15+
fig, axes = plt.subplots(1, cols, figsize=(8, 8))
16+
17+
for x, city in enumerate(df_city.city.value_counts().index.values):
18+
data = df_city[(df_city['city'] == city)]
19+
data = data.groupby(['industry']).jobs.sum()
20+
print (data)
21+
print type(data.index)
22+
left= [k[0] for k in enumerate(data)]
23+
right= [k[1] for k in enumerate(data)]
24+
25+
axes[x].bar(left,right,label="%s" % (city))
26+
axes[x].set_xticks(left, minor=False)
27+
axes[x].set_xticklabels(data.index.values)
28+
29+
axes[x].legend(loc='best')
30+
axes[x].grid(True)
31+
fig.suptitle('Employment By Industry By City', fontsize=20)
32+
plt.show(1)
33+
34+
from ggplot import *
35+
36+
print ggplot(aes(x='city'), data=df_city) + geom_bar() + facet_grid(x=None, y="city", nrow=1)

tutorial/02 - Stats, Facets, and Scaling.ipynb

Lines changed: 30 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)