Visualizing Honey Production 🍯 🐝¢

import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
honey = pd.read_csv('../../../data/honey.csv')
honey.head()

Use a scatterplot to show the relationship between a state and its price per pound for local honey

sns.relplot(x="priceperlb", y="state", data=honey, height=15, aspect=.5);

Show this relationship plus a new yellow-colored scatterplot with hue determined by year.

sns.relplot(x="priceperlb", y="state", hue="year", palette="YlOrBr", data=honey, height=15, aspect=.5);

Try this plot one more time, this time showing the price change by size of the dot in the scatterplot

sns.relplot(x="priceperlb", y="state", size="year", data=honey, height=15, aspect=.5);

Explore some line charting options

sns.relplot(x="year", y="priceperlb", kind="line", data=honey);
sns.relplot(x="year", y="totalprod", kind="line", data=honey);

Build a facet grid

sns.relplot(
    data=honey, 
    x="yieldpercol", y="numcol",
    col="year", 
    col_wrap=3,
    kind="line"
)

Create a dual line plot (this solution is suggested by Kedar Ghule: https://kedar.hashnode.dev/how-to-combine-two-line-charts-in-seaborn-and-python)

fig, ax = plt.subplots(figsize=(12,6))
lineplot = sns.lineplot(x=honey['year'], y=honey['numcol'], data=honey, 
                        label = 'Number of bee colonies', legend=False)
sns.despine()
plt.ylabel('# colonies')
plt.title('Honey Production Year over Year');

ax2 = ax.twinx()
lineplot2 = sns.lineplot(x=honey['year'], y=honey['yieldpercol'], ax=ax2, color="r", 
                         label ='Yield per colony', legend=False) 
sns.despine(right=False)
plt.ylabel('colony yield')
ax.figure.legend();