skills/43-wentorai-research-plugins/skills/analysis/dataviz/python-dataviz-guide/SKILL.md
Publication-quality data visualization with matplotlib, seaborn, and plotly
npx skillsauth add brycewang-stanford/Awesome-Agent-Skills-for-Empirical-Research python-dataviz-guideInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Data visualization is how researchers communicate quantitative findings. A well-designed figure can convey complex relationships instantly, while a poor one buries the signal in clutter. Python's visualization ecosystem -- anchored by matplotlib, seaborn, and plotly -- provides everything needed to produce publication-quality figures for journals, conferences, and presentations.
This guide covers the three major Python visualization libraries, their strengths and trade-offs, and concrete recipes for the chart types researchers use most frequently. Each example is designed to be copy-paste ready and customizable for your specific dataset and venue requirements.
The emphasis is on producing figures that meet journal standards: correct DPI, appropriate font sizes, accessible color palettes, and vector-format exports. We also cover interactive visualization with plotly for exploratory analysis and supplementary materials.
Matplotlib is the most flexible Python plotting library. Nearly every other visualization tool in the Python ecosystem builds on it.
import matplotlib.pyplot as plt
import matplotlib as mpl
# Publication-quality defaults
plt.rcParams.update({
'figure.figsize': (6, 4),
'figure.dpi': 150,
'savefig.dpi': 300,
'savefig.bbox': 'tight',
'font.size': 11,
'font.family': 'serif',
'font.serif': ['Times New Roman'],
'axes.labelsize': 12,
'axes.titlesize': 13,
'xtick.labelsize': 10,
'ytick.labelsize': 10,
'legend.fontsize': 10,
'lines.linewidth': 1.5,
'lines.markersize': 6,
'axes.grid': True,
'grid.alpha': 0.3,
})
import numpy as np
epochs = np.arange(1, 51)
acc_mean = 1 - 0.5 * np.exp(-epochs / 10)
acc_std = 0.03 * np.exp(-epochs / 20)
fig, ax = plt.subplots()
ax.plot(epochs, acc_mean, label='Our Method', color='#2563EB')
ax.fill_between(epochs, acc_mean - acc_std, acc_mean + acc_std,
alpha=0.2, color='#2563EB')
ax.set_xlabel('Epoch')
ax.set_ylabel('Accuracy')
ax.set_ylim(0.4, 1.0)
ax.legend(frameon=False)
fig.savefig('accuracy_curve.pdf') # Vector format for papers
fig, axes = plt.subplots(1, 3, figsize=(15, 4), sharey=True)
for ax, dataset, color in zip(axes, ['CIFAR-10', 'ImageNet', 'COCO'],
['#2563EB', '#DC2626', '#16A34A']):
x = np.random.randn(200)
ax.hist(x, bins=30, color=color, alpha=0.7, edgecolor='white')
ax.set_title(dataset)
ax.set_xlabel('Score Distribution')
axes[0].set_ylabel('Count')
plt.tight_layout()
fig.savefig('multi_panel.pdf')
Seaborn excels at statistical graphics with minimal code. It handles data frames natively and produces polished output by default.
import seaborn as sns
import pandas as pd
data = pd.DataFrame({
'Method': ['Baseline', 'Baseline', 'Ours', 'Ours', 'Ours+FT', 'Ours+FT'],
'Metric': ['BLEU', 'ROUGE'] * 3,
'Score': [34.2, 45.1, 41.8, 52.3, 48.5, 58.7]
})
fig, ax = plt.subplots(figsize=(8, 5))
sns.barplot(data=data, x='Metric', y='Score', hue='Method',
palette=['#94A3B8', '#3B82F6', '#EF4444'], ax=ax)
ax.set_ylabel('Score')
ax.legend(title='Method', frameon=False)
fig.savefig('comparison.pdf')
corr_matrix = pd.DataFrame(
np.random.randn(8, 8),
columns=[f'Feature {i}' for i in range(8)]
).corr()
fig, ax = plt.subplots(figsize=(8, 7))
sns.heatmap(corr_matrix, annot=True, fmt='.2f', cmap='RdBu_r',
center=0, square=True, linewidths=0.5, ax=ax)
ax.set_title('Feature Correlation Matrix')
fig.savefig('heatmap.pdf')
df = pd.DataFrame({
'Group': np.repeat(['Control', 'Treatment A', 'Treatment B'], 100),
'Value': np.concatenate([
np.random.normal(50, 10, 100),
np.random.normal(55, 8, 100),
np.random.normal(60, 12, 100)
])
})
fig, ax = plt.subplots(figsize=(8, 5))
sns.violinplot(data=df, x='Group', y='Value', palette='Set2',
inner='box', ax=ax)
ax.set_ylabel('Measurement')
fig.savefig('violin.pdf')
Plotly is ideal for exploratory analysis and HTML-based supplementary materials.
import plotly.express as px
df = px.data.gapminder().query("year == 2007")
fig = px.scatter(df, x="gdpPercap", y="lifeExp",
size="pop", color="continent",
hover_name="country",
log_x=True, size_max=60,
title="GDP vs Life Expectancy (2007)")
fig.write_html("interactive_scatter.html")
fig.write_image("scatter.pdf") # Requires kaleido
| Data Relationship | Recommended Chart | Library | |-------------------|-------------------|---------| | Trend over time | Line plot | matplotlib | | Distribution | Histogram, violin, box | seaborn | | Comparison (categories) | Bar chart, grouped bar | seaborn | | Correlation (2 vars) | Scatter plot | matplotlib/plotly | | Correlation (matrix) | Heatmap | seaborn | | Part-to-whole | Stacked bar (not pie) | matplotlib | | High-dimensional | PCA/t-SNE scatter | plotly | | Geospatial | Choropleth | plotly |
sns.color_palette("colorblind") or use tools like ColorBrewer.development
Conduct rigorous thematic analysis (TA) of qualitative data following Braun and Clarke's (2006) six-phase framework. Use whenever the user mentions 'thematic analysis', 'TA', 'Braun and Clarke', 'qualitative coding', 'identifying themes', or asks for help analysing interviews, focus groups, open-ended survey responses, or transcripts to identify patterns. Also trigger for questions about inductive vs theoretical coding, semantic vs latent themes, essentialist vs constructionist epistemology, building a thematic map, or writing up a qualitative findings section. Covers all six phases, the four upfront analytic decisions, the 15-point quality checklist, and the five common pitfalls. Produces a Word document write-up and an annotated thematic map. Does NOT cover IPA, grounded theory, discourse analysis, conversation analysis, or narrative analysis — use a different method for those.
development
Guide users through writing a systematic literature review (SLR) following the PRISMA 2020 framework. Use this skill whenever the user mentions 'systematic review', 'systematic literature review', 'SLR', 'PRISMA', 'PRISMA 2020', 'PRISMA flow diagram', 'PRISMA checklist', or asks for help writing, structuring, or auditing a literature review that follows reporting guidelines. Also trigger when the user asks about inclusion/exclusion criteria for a review, search strategies for databases like Scopus/WoS/PubMed, study selection processes, risk of bias assessment, or narrative synthesis for a review paper. This skill covers the full PRISMA 2020 checklist (27 items), produces a Word document manuscript in strict journal article format, generates an annotated PRISMA flow diagram, and enforces APA 7th Edition referencing throughout. It does NOT cover meta-analysis or statistical pooling. By Chuah Kee Man.
testing
Performs placebo-in-time sensitivity analysis with hierarchical null model and optional Bayesian assurance. Use when checking model robustness, verifying lack of pre-intervention effects, or estimating study power.
data-ai
Fit, summarize, plot, and interpret a chosen CausalPy experiment. Use after the causal method has been selected, including when configuring PyMC/sklearn models and scale-aware custom priors.