Introduction to Data Visualization with Seaborn
palette_colors = {"Rural": "green", "Urban": "blue"} sns.countplot(x="school",
data=student_data, hue="location", palette=palette_colors)
Here's a summary of the functions and methods used across the examples:
1. Scatter Plots:
o sns.scatterplot(): Creates a basic scatter plot with two variables,
where x is plotted on the x-axis and y on the y-axis.
o sns.relplot(): A flexible function that can create scatter plots
(kind="scatter") and line plots (kind="line") with additional support
for creating subplots using row and col. It also allows adding
subgroups with hue, size, and style.
2. Count Plots:
o sns.countplot(): Creates a count plot for categorical data, counting
occurrences of values in a column and representing them as bars.
3. Subplots with Rows and Columns:
o sns.relplot() with col or row: Creates multiple subplots based on
unique values in a categorical column. This method allows breaking
down a plot into multiple small plots based on the column’s levels,
either arranged in columns (col) or rows (row).
4. Hue and Style:
o hue: Used to color points differently based on the values in a
categorical column.
o style: Changes the style (such as shape or pattern) of points or lines
based on the values in a categorical column.
o hue_order and row_order/col_order: Control the order of categories
in the hue, row, and col subplots.
5. Line Plots:
o sns.relplot(kind="line"): Creates line plots with x and y variables.
This is similar to scatterplot but visualizes continuous data over time
or progression.
o ci: Stands for confidence interval. By default, a shaded region
represents a 95% confidence interval, but this can be turned off
(ci=None) or changed to show the standard deviation (ci="sd").
o markers=True: Adds markers at each data point in a line plot.
o dashes=False: Ensures all lines are solid, but still varies the marker
styles for each line.
6. Subgrouping in Line and Scatter Plots:
o hue and style: Can be used to divide the data into subgroups and
visually differentiate them using different colors or styles in line and
scatter plots.
o dashes=False: Forces solid lines even when using style for
differentiation by markers instead of line types.