In [1]:
%matplotlib inline
from ggplot import *
import pandas as pd

facet_grid

Parameters

  • first facet
  • second facet (optional)
  • scales ("fixed" (default), "free", "free_x", "free_y")

In [2]:
ggplot(diamonds, aes(x='price')) + \
    geom_histogram() + \
    facet_grid("cut")


Out[2]:
<ggplot: (284492721)>

In [3]:
ggplot(diamonds, aes(x='price')) + \
    geom_histogram() + \
    facet_grid("cut", "clarity")


Out[3]:
<ggplot: (285347789)>

In [4]:
chopsticks.head()


Out[4]:
food_pinching_effeciency individual chopstick_length
0 19.55 1 180
1 27.24 2 180
2 28.76 3 180
3 31.19 4 180
4 21.91 5 180

In [5]:
ggplot(chopsticks, aes(x='chopstick_length', y='food_pinching_effeciency')) + \
    geom_point() + \
    facet_grid("individual")


Out[5]:
<ggplot: (292115357)>

In [6]:
meat_lng = pd.melt(meat[['date', 'beef', 'pork', 'veal']], id_vars=['date'])

ggplot(meat_lng, aes(x='value')) + \
    geom_histogram() + \
    facet_grid("variable")


Out[6]:
<ggplot: (299321897)>

In [7]:
ggplot(meat_lng, aes(x='value')) + \
    geom_histogram() + \
    facet_grid(None, "variable")


Out[7]:
<ggplot: (298221653)>

In [8]:
ggplot(meat_lng, aes(x='value')) + \
    geom_density() + \
    facet_grid(None, "variable")


Out[8]:
<ggplot: (299999177)>

In [9]:
ggplot(meat_lng, aes(x='value')) + \
    geom_density() + \
    facet_grid("variable")


Out[9]:
<ggplot: (300363609)>

In [ ]: