06 02 Visualizing Two Quantitative Variables - HannaAA17/Data-Scientist-With-Python-datacamp GitHub Wiki
- relational plots
Intro to relational plots and subplots
relplot()
: to create scatter plots or line plotsrelplot()
lets us create subplots in a single figure- need to specify
kind="scatter"
orkind="line"
Subplots in row and/or columns
sns.relplot(x='total_bill'
y='tip',
data=tips,
kind='scatter',
col='smoker',
row='time')
- wrapping columns: change the number of plot per row
col_wraps=2
- ordering columns
col_order=['Mon','Tue','Wed']
Customizing scatter plots
- Subplots (
col
androw
) - Subgroups with color (
hue
) - Subgroups with point size and style:
style='smoker'
andsize='smoker'
- Changing point transparency:
alpha=0.4
Introduction to line plots
- adding markers:
markers=True
- turning off line style:
dashes=False
Multiple observations per x-value
sns.relplot(x='hour', y='NO_2', data=air_df, kind='line')
Shaded region is the confidence interval
- Assumes dataset is a random sample
- 95% confident that the mean is within this interval
- Indicates uncertainty in our estimate
- Replacing confidence interval with standard deviation:
ci='sd'
- Turning off confidence in interval: 'ci=None`