■ Seaborn Graphs - Detailed Notes with Examples
■ Line Plot
Function: sns.lineplot()
Use Case: Used to visualize trends between continuous variables, often over time or ordered
categories.
Important Parameters: x, y, data, hue, style, size, palette, markers, dashes, linewidth, errorbar,
estimator
Example:
sns.lineplot(x="Age", y="Income", data=df, hue="Gender", style="Gender",
markers=True, dashes=False)
■ Scatter Plot
Function: sns.scatterplot()
Use Case: Show relationship between two numeric variables, useful for spotting clusters or
outliers.
Important Parameters: x, y, data, hue, style, size, palette, marker, alpha, legend
Example:
sns.scatterplot(x="Age", y="Income", data=df, hue="Gender",
style="Gender", size="Experience")
■ Bar Plot
Function: sns.barplot()
Use Case: Compare categories using aggregated values (default = mean).
Important Parameters: x, y, data, hue, estimator, ci, capsize, errwidth, dodge, orient, palette
Example:
sns.barplot(x="Department", y="Salary", data=df, hue="Gender", ci=None)
■ Count Plot
Function: sns.countplot()
Use Case: Counts frequency of categories.
Important Parameters: x, y, data, hue, order, palette, orient
Example:
sns.countplot(x="Department", data=df, hue="Gender")
■ Box Plot
Function: sns.boxplot()
Use Case: Summarize distribution (median, quartiles, outliers).
Important Parameters: x, y, data, hue, order, palette, orient, width, linewidth, showfliers
Example:
sns.boxplot(x="Department", y="Salary", data=df, hue="Gender")
■ Violin Plot
Function: sns.violinplot()
Use Case: Distribution + density + summary statistics.
Important Parameters: x, y, data, hue, split, scale, inner, bw, cut, palette
Example:
sns.violinplot(x="Department", y="Salary", data=df, hue="Gender",
split=True)
■ Strip Plot
Function: sns.stripplot()
Use Case: Individual data points with jitter (can overlap).
Important Parameters: x, y, data, hue, jitter, size, dodge, alpha, palette
Example:
sns.stripplot(x="Department", y="Salary", data=df, hue="Gender",
jitter=True)
■ Swarm Plot
Function: sns.swarmplot()
Use Case: Like strip plot but avoids overlap of points.
Important Parameters: x, y, data, hue, dodge, size, palette
Example:
sns.swarmplot(x="Department", y="Salary", data=df, hue="Gender")
■ Histogram
Function: sns.histplot()
Use Case: Distribution of a variable with bins.
Important Parameters: x, y, data, bins, binwidth, binrange, discrete, stat, kde, hue, multiple
Example:
sns.histplot(data=df, x="Age", bins=20, kde=True, hue="Gender",
multiple="stack")
■ KDE Plot
Function: sns.kdeplot()
Use Case: Smooth probability density estimation.
Important Parameters: x, y, data, hue, bw_adjust, fill, multiple, common_norm
Example:
sns.kdeplot(data=df, x="Age", hue="Gender", fill=True)
■ Rug Plot
Function: sns.rugplot()
Use Case: Small ticks showing individual data points along an axis.
Important Parameters: x, y, data, hue, height, expand_margins, palette
Example:
sns.rugplot(data=df, x="Age", hue="Gender")
■ ECDF Plot
Function: sns.ecdfplot()
Use Case: Cumulative distribution function.
Important Parameters: x, data, hue, stat, complementary
Example:
sns.ecdfplot(data=df, x="Age", hue="Gender")
■ Pair Plot
Function: sns.pairplot()
Use Case: Matrix of plots between multiple variables.
Important Parameters: data, vars, hue, palette, diag_kind, kind, corner
Example:
sns.pairplot(df, hue="Gender", diag_kind="kde")
■ Joint Plot
Function: sns.jointplot()
Use Case: Scatterplot + marginal distributions (hist/kde).
Important Parameters: x, y, data, kind, hue, palette
Example:
sns.jointplot(x="Age", y="Income", data=df, kind="hex", hue="Gender")
■ Heatmap
Function: sns.heatmap()
Use Case: Visualize 2D data as color-coded matrix (e.g., correlation).
Important Parameters: data, annot, fmt, cmap, cbar, linewidths, linecolor, square, mask, vmin,
vmax
Example:
sns.heatmap(df.corr(), annot=True, cmap="coolwarm")
■ Clustermap
Function: sns.clustermap()
Use Case: Heatmap with hierarchical clustering.
Important Parameters: data, method, metric, cmap, standard_scale, z_score, row_cluster,
col_cluster
Example:
sns.clustermap(df.corr(), cmap="viridis", standard_scale=1)
■ Regression Plot
Function: sns.regplot()
Use Case: Scatter + regression line fit.
Important Parameters: x, y, data, ci, order, robust, scatter_kws, line_kws, logistic
Example:
sns.regplot(x="Age", y="Income", data=df, ci=None)
■ LM Plot
Function: sns.lmplot()
Use Case: Regression plot with categorical facets.
Important Parameters: x, y, data, hue, col, row, ci, order, logistic
Example:
sns.lmplot(x="Age", y="Income", data=df, hue="Gender", col="Department")
■ Cat Plot
Function: sns.catplot()
Use Case: High-level categorical plot (wrapper: bar, box, violin, etc.).
Important Parameters: x, y, data, hue, col, row, kind, height, aspect, order, dodge
Example:
sns.catplot(x="Department", y="Salary", data=df, hue="Gender",
kind="box")
■ Rel Plot
Function: sns.relplot()
Use Case: High-level relational plot (scatter/line with facets).
Important Parameters: x, y, data, hue, size, style, col, row, kind, height, aspect
Example:
sns.relplot(x="Age", y="Income", data=df, hue="Gender", kind="line",
col="Department")