January 5, 2020
SEABORN
Seaborn is a Python data visualization library that provides simple code to create elegant visualizations for statistical exploration and insight.
Compared to Matplotlib:
- Seaborn provides a more visually appealing plotting style and concise syntax.
- Seaborn natively understands Pandas DataFrames, making it easier to plot data directly from csv files.
- Seaborn can easily summerize Pandas DataFrames with many rows of data into aggregated charts.
To create a DataFrame from a local csv file:
df = pd.read_csv(‘file.csv’)
The Seaborn function sns.barplot( ) takes at least 3 arguments
- data - a Pandas DataFrame
- X - a string that tells Seaborn which column in the DataFrame contains X axis labels
- Y - a string that tells Seaborn which column in the DataFrame contains Y axis heights.
import seaborn as sns
sns.barplot(data = df, x = ‘Gender’, y = ‘Mean’)
plt.show( )
By default, Seaborn will place error bars on each bar when you use the barplot function.
Error Bars visually indicate the range of values that might be expected for that bar.
By default, Seaborn uses bootstrapped confidence interval.
- 95% of similar situations would have an outcome within this range.
If you would prefer Standard Deviation for your error bars, you can pass the keyword argument ci=”sd” to sns.barplot( )