Hist
by gordonwatts
Use when working with the scikit-hep hist library in Python to create, fill, slice, and plot histograms (1D/2D/multi-axis), including UHI indexing, categorical axes, and mplhep plotting conventions.
Skill Details
Repository Files
4 files in this skill directory
name: hist description: Use when working with the scikit-hep hist library in Python to create, fill, slice, and plot histograms (1D/2D/multi-axis), including UHI indexing, categorical axes, and mplhep plotting conventions.
Hist
Overview
Use this skill to build and manipulate hist.Hist objects, choose axis/storage types, fill with data and weights, and produce publication-style plots with mplhep styles, all based on matplotlib.
Quick start
- Create histograms with
Hist.newplus axis builders (Reg,Var,StrCat) and finish with exactly one storage (Int64orWeight). - Make sure axis labels contain a short variable name and units. Histogram titles should contains a slightly longer concise description of what data went into the plot.
- Fill with
.fill(...)using axis names; note that.fillreturnsNone. - Slice or project with UHI indexing (e.g.,
h.project("x")orh[{"x": 5j}]). - Plot with
hist.plot(...)ormplhep.hist2dplot(...); useplt.style.use(hep.style.ATLAS)for HEP-style plots.
Core tasks
Create axes and storage
- Use
Regfor uniform bins andVarfor variable-width bins. - Use
StrCatfor categorical axes; setgrowth=Truefor auto-added categories. - Choose storage:
Int64for unweighted counts,Weightfor weighted fills.
Fill and access contents
- Fill with named axes (e.g.,
h.fill(x=..., y=..., weight=...)). - Read counts with
h.view()and errors fromnp.sqrt(h.variances()).
Slice, rebin, and project
- Use UHI slicing (complex numbers for bin selection,
::2jfor rebinning). - Project with
h.project("axis_name")for 1D plots.
Plot and save
- Use
hist.plot(histtype="fill")for 1D; usemplhep.hist2dplotfor 2D. - Use
plt.subplots()without customfigsizeunless explicitly requested. - Save with
fig.savefig("name.png")and close withplt.close(fig).
References
- Use
references/hist-hints.mdfor concrete code snippets and common patterns. - Use
references/hist-advanced.mdfor UHI indexing, plotting gotchas, and label/LaTeX guidance. - Use
references/lhc-hist-ranges.mdfor starting suggestions on histogram axis ranges and binning.
Related Skills
Attack Tree Construction
Build comprehensive attack trees to visualize threat paths. Use when mapping attack scenarios, identifying defense gaps, or communicating security risks to stakeholders.
Grafana Dashboards
Create and manage production Grafana dashboards for real-time visualization of system and application metrics. Use when building monitoring dashboards, visualizing metrics, or creating operational observability interfaces.
Matplotlib
Foundational plotting library. Create line plots, scatter, bar, histograms, heatmaps, 3D, subplots, export PNG/PDF/SVG, for scientific visualization and publication figures.
Scientific Visualization
Create publication figures with matplotlib/seaborn/plotly. Multi-panel layouts, error bars, significance markers, colorblind-safe, export PDF/EPS/TIFF, for journal-ready scientific plots.
Seaborn
Statistical visualization. Scatter, box, violin, heatmaps, pair plots, regression, correlation matrices, KDE, faceted plots, for exploratory analysis and publication figures.
Shap
Model interpretability and explainability using SHAP (SHapley Additive exPlanations). Use this skill when explaining machine learning model predictions, computing feature importance, generating SHAP plots (waterfall, beeswarm, bar, scatter, force, heatmap), debugging models, analyzing model bias or fairness, comparing models, or implementing explainable AI. Works with tree-based models (XGBoost, LightGBM, Random Forest), deep learning (TensorFlow, PyTorch), linear models, and any black-box model
Pydeseq2
Differential gene expression analysis (Python DESeq2). Identify DE genes from bulk RNA-seq counts, Wald tests, FDR correction, volcano/MA plots, for RNA-seq analysis.
Query Writing
For writing and executing SQL queries - from simple single-table queries to complex multi-table JOINs and aggregations
Pydeseq2
Differential gene expression analysis (Python DESeq2). Identify DE genes from bulk RNA-seq counts, Wald tests, FDR correction, volcano/MA plots, for RNA-seq analysis.
Scientific Visualization
Meta-skill for publication-ready figures. Use when creating journal submission figures requiring multi-panel layouts, significance annotations, error bars, colorblind-safe palettes, and specific journal formatting (Nature, Science, Cell). Orchestrates matplotlib/seaborn/plotly with publication styles. For quick exploration use seaborn or plotly directly.
