Plotnine flipbook
In [1]:
Copied!
from plotnine import *
from plotnine import *
In [2]:
Copied!
import pandas as pd
import pandas as pd
In [21]:
Copied!
df = pd.read_csv("christmas tree sales.csv")
df.head()
df = pd.read_csv("christmas tree sales.csv")
df.head()
Out[21]:
Year | Type of tree | Trees sold (millions) | |
---|---|---|---|
0 | 2004 | Real tree | 27.1 |
1 | 2005 | Real tree | 32.8 |
2 | 2006 | Real tree | 28.6 |
3 | 2007 | Real tree | 31.3 |
4 | 2008 | Real tree | 28.2 |
In [22]:
Copied!
ggplot(df)
ggplot(df)
Out[22]:
<ggplot: (318247485)>
In [23]:
Copied!
ggplot(df) + aes(x='Year')
ggplot(df) + aes(x='Year')
Out[23]:
<ggplot: (318484294)>
In [24]:
Copied!
(
ggplot(df)
+ aes(x='Year')
)
(
ggplot(df)
+ aes(x='Year')
)
Out[24]:
<ggplot: (318513011)>
In [26]:
Copied!
(
ggplot(df)
+ aes(x='Year')
+ aes(y='Trees sold (millions)')
)
(
ggplot(df)
+ aes(x='Year')
+ aes(y='Trees sold (millions)')
)
Out[26]:
<ggplot: (318569960)>
In [28]:
Copied!
(
ggplot(df)
+ aes(x='Year')
+ aes(y='Trees sold (millions)')
+ geom_point()
)
(
ggplot(df)
+ aes(x='Year')
+ aes(y='Trees sold (millions)')
+ geom_point()
)
Out[28]:
<ggplot: (318323523)>
In [29]:
Copied!
(
ggplot(df)
+ aes(x='Year')
+ aes(y='Trees sold (millions)')
+ geom_point()
+ aes(color='Type of tree')
)
(
ggplot(df)
+ aes(x='Year')
+ aes(y='Trees sold (millions)')
+ geom_point()
+ aes(color='Type of tree')
)
Out[29]:
<ggplot: (318157629)>
In [ ]:
Copied!