Seaborn provides a easy framework to edit matplotlib charts. Pandas pulls in the data. sns.set allows a one set default for the program.
In [49]:
import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
sns.set(style="ticks", context='talk', font_scale=1.1)
%matplotlib inline
Read the csv file into a panda
In [50]:
df = pd.read_csv('top10mountain-lions.csv')
Chart 1 features a whitegrid style to help assign a number to each bar. Despine removes Tufte's chart junk.
In [51]:
sns.set_style("whitegrid")
sns.barplot(x="count", y="COUNTY", data=df, color="#2ecc71")
sns.despine(bottom=True, left=True)
Chart 2 features a white chart style. Y label is removed because county label is redudant. Also, X label is more useful. Despine removes Tufte's chart junk.
I think this chart is the most effective although I would decrease the scale to every 10. Another weakness is probably a locational aspect to the sightings and that relationship isn't shown in the bar chart.
In [52]:
sns.set_style("white")
sns.barplot(x="count", y="COUNTY", data=df, color="#f6a14e")
plt.ylabel('')
plt.xlabel('Mountain Lion Sightings')
sns.despine(bottom=True, left=True)
Chart 3 features a dark grid style. Although the grid helps assign values to the bars, the color is distracting and tends to chart junk
In [53]:
sns.set_style("darkgrid")
sns.barplot(x="count", y="COUNTY", data=df, color="#7fe5ba")
plt.ylabel('')
plt.xlabel('Mountain Lion Sightings')
sns.despine(bottom=True, left=True)