Plotting Overview
Data visualization is essential for exploring, understanding, and communicating insights from data. This guide covers common plot types, their purposes, and when to use them.
Table of Contents
1. Plot Selection Guide
1.1. By Analysis Goal
| Goal | Recommended Plot Types |
|---|---|
| Understand distribution of single variable | Histogram, Box plot, Violin plot, Density plot |
| Compare groups | Box plot, Violin plot, Bar chart, Strip plot |
| Find relationships between variables | Scatter plot, Line plot, Regression plot, Heatmap |
| Show composition | Pie chart, Stacked bar chart, Area plot |
| Analyze time series | Line plot, Area plot, Seasonal plot |
| Detect outliers | Box plot, Scatter plot, Strip plot |
| Explore multivariate data | Pair plot, Correlation heatmap, Facet grid |
| Check statistical assumptions | Q-Q plot, Residual plot, Histogram |
| Show uncertainty | Error bars, Confidence bands, Violin plots |
1.2. By Data Type Combination
| X Variable | Y Variable | Z Variable (optional) | Recommended Plots |
|---|---|---|---|
| Categorical | None | None | Bar chart, Pie chart, Count plot |
| Continuous | None | Box plot, Violin plot, Bar chart, Strip plot | |
| Categorical | None | Heatmap, Stacked bar chart, Grouped bar chart | |
| Continuous | None | None | Histogram, Box plot, Violin plot, Density plot |
| Continuous | None | Scatter plot, Line plot, Hexbin, 2D density | |
| Continuous | 3D scatter, Bubble chart, Contour plot | ||
| Categorical | Scatter with hue, Facet grid |
2. Best Practices
2.1. General Guidelines
- Choose the right plot for your data type and message
- Match plot type to data structure (categorical vs continuous)
- Consider what you want to communicate
- Keep it simple
- Avoid unnecessary 3D effects
- Remove chart junk (excessive gridlines, decorations)
- Use appropriate aspect ratios
- Use color effectively
- Use color to encode information, not just for decoration
- Ensure accessibility (colorblind-friendly palettes)
- Maintain consistency across related plots
- Label clearly
- Always include axis labels with units
- Add informative titles
- Include legends when needed
- Annotate important points
- Consider your audience
- Technical vs general audience
- Level of detail appropriate for context
- Medium of presentation (paper, screen, presentation)
2.2. Common Mistakes to Avoid
| Mistake | Problem | Solution |
|---|---|---|
| Starting y-axis at non-zero | Exaggerates differences | Start at zero for bar charts; flexible for line plots |
| Too many categories | Cluttered, hard to read | Limit to 7-10 categories; consider grouping or filtering |
| 3D when 2D suffices | Distorts perception, hard to read | Use 2D alternatives with color or size |
| Pie charts with many slices | Hard to compare angles | Use bar chart instead |
| Dual y-axes | Can be misleading | Use separate plots or normalize scales |
| Missing error bars | Unclear uncertainty | Add error bars or confidence intervals |
| Poor color choices | Not colorblind-safe, poor contrast | Use established palettes (ColorBrewer, Seaborn) |
| Overplotting | Too many overlapping points | Use transparency, jitter, hexbin, or sample data |
3. Common Plot Types by Data Type and Purpose
3.1. Univariate Plots (Single Variable)
3.2. Bivariate Plots (Two Variables)
3.3. Multivariate Plots (Three or More Variables)
3.4. Specialized Statistical Plots
3.5. Time Series Plots
4. Additional Resources
4.1. Python Visualization Libraries
| Library | Strengths | Best For | Import Statement |
|---|---|---|---|
| Matplotlib | Highly customizable, fine control | Publication-quality plots, custom visualizations | import matplotlib.pyplot as plt |
| Seaborn | Beautiful defaults, statistical plots | Exploratory data analysis, statistical visualization | import seaborn as sns |
| Pandas | Integrated with DataFrames | Quick exploration, simple plots | Built-in: df.plot() |
| Plotly | Interactive plots, 3D support | Dashboards, web applications, interactive exploration | import plotly.express as px |
| Bokeh | Interactive web-ready plots | Interactive dashboards, streaming data | from bokeh.plotting import figure |
4.2. Recommended Reading
- “The Visual Display of Quantitative Information” by Edward Tufte
- “Fundamentals of Data Visualization” by Claus O. Wilke
- “Storytelling with Data” by Cole Nussbaumer Knaflic
4.3. Python Plotting Resources
- ColorBrewer: Color schemes for maps and data visualization
- Seaborn Gallery: Examples of statistical plots
- Matplotlib Gallery: Comprehensive plot examples
- Python Graph Gallery: Collection of plot types with code
4.4. Color Palettes
# Colorblind-friendly palettes
sns.color_palette("colorblind")
sns.color_palette("Set2")
# Diverging (for correlation matrices)
sns.color_palette("RdBu_r", as_cmap=True)
sns.color_palette("coolwarm", as_cmap=True)
# Sequential (for heatmaps)
sns.color_palette("YlOrRd", as_cmap=True)
sns.color_palette("viridis", as_cmap=True)


































