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

facet_wrap

Parameters

  • first facet
  • second facet (optional)
  • nrow- number of rows
  • ncol- number of columns
  • scales ("fixed" (default), "free", "free_x", "free_y")

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


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

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


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

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_wrap("individual")


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

In [6]:
ggplot(chopsticks, aes(x='chopstick_length', y='food_pinching_effeciency')) + \
    geom_point() + \
    facet_wrap("individual", nrow=10)


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

In [7]:
ggplot(chopsticks, aes(x='chopstick_length', y='food_pinching_effeciency')) + \
    geom_point() + \
    facet_wrap("individual", ncol=10)


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

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


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

In [9]:
ggplot(chopsticks, aes(x='chopstick_length', y='food_pinching_effeciency')) + \
    geom_point() + \
    geom_line() + \
    scale_x_continuous(breaks=[150, 250, 350]) + \
    facet_wrap("individual")


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

In [ ]: