Data Visualization & Figures.
Publication-quality figures generated through AI-assisted workflows.
After this lesson you'll know
- How to use AI to generate publication-ready matplotlib, seaborn, and plotly code
- Journal figure requirements and how to meet them programmatically
- Choosing the right visualization for your data type and audience
- Building a reusable figure generation pipeline
Why AI Changes Research Visualization
Research visualization has two problems. First, the conceptual problem: choosing the right chart type for your data and message. Second, the implementation problem: writing matplotlib code that produces figures meeting journal specifications (DPI, font sizes, color accessibility, panel layouts). AI solves the second problem almost completely. You describe what you want, AI generates the code, you run it. The first problem -- choosing what to visualize and why -- remains yours. A beautiful figure that shows the wrong thing is worse than an ugly figure that shows the right thing.
Figure-first analysis: Before running statistics, visualize your data. Distributions, scatter plots, and time series often reveal patterns, outliers, and violations of assumptions that summary statistics hide. Anscombe's quartet proved this in 1973 -- identical statistics, completely different patterns.
The Figure Generation Prompt
Precision in your prompt produces publication-quality code on the first attempt: ```python FIGURE_PROMPT = """ Generate matplotlib/seaborn code for a publication-quality figure. DATA: - DataFrame 'df' with columns: {columns} - Sample data: {first_3_rows} FIGURE SPEC: - Type: {chart_type} - X-axis: {x_variable} (label: "{x_label}") - Y-axis: {y_variable} (label: "{y_label}") - Grouping: {group_variable} if applicable - Error bars: {SEM / 95% CI / SD} JOURNAL REQUIREMENTS: - Figure width: {single_column: 3.5in / double_column: 7in} - DPI: 300 minimum (600 for line art) - Font: Arial or Helvetica, 8pt minimum - Color: accessible palette (colorblind-safe) - File format: PDF and TIFF STYLE RULES: - Remove top and right spines - Use direct labels instead of legends when possible - Grayscale-safe (patterns/markers differ, not just color) - Statistical annotations: brackets with p-values or stars Generate the complete code including: 1. Figure setup with exact dimensions 2. Data plotting with proper aesthetics 3. Statistical annotations if applicable 4. Axis formatting and labels 5. Save in both PDF and TIFF at required DPI """ ```
The "Nature style" shortcut: If you're targeting a specific journal, tell the AI: "Style this figure to match Nature / Science / PNAS conventions." The model knows the common style guidelines and will generate code that matches. Always verify against the actual journal's figure guidelines, but this gets you 90% of the way.
This lesson is for Pro members
Unlock all 518+ lessons across 52 courses with Academy Pro.
Already a member? Sign in to access your lessons.