Command Line¶
The cplots command makes triangle plots from MCMC chains and line plots from
data files without writing any Python.
Run cplots --help, or --help on any command, for the full option list.
| Command | What it does |
|---|---|
cplots info CHAIN |
Print sample count, weights and parameter names of a chain |
cplots distributions triangle CHAIN |
Triangle (corner) plot from MCMC chains |
cplots lines xy FILE |
Plot columns of a data file against one another |
cplots config set\|get\|unset\|show |
Manage persistent defaults |
Inspect a chain¶
CHAIN is a chain file, a chain root prefix (GetDist or cobaya), or a directory
holding one root. Start here to find the parameter names:
cplots info chains/planck_TTTEEE
cplots info chains/run.1.txt --skip 0.3 # discard the first 30% as burn-in
Triangle plots¶
# Pick parameters interactively, preview in a window
cplots distributions triangle chains/planck_TTTEEE
# Three parameters, in this order, as a PRD-sized PDF
cplots distributions triangle chains/ -p Omega_m,sigma8,H0 --paper-format PRD -o fig.pdf
# Truth lines and label overrides from YAML, ChainConsumer engine
cplots distributions triangle chains/ -p Omega_m,sigma8 --config truths.yaml \
--engine chainconsumer -o corner.png
Without --params, an interactive selector lists the chain's parameters (this
needs a terminal). Parameter labels come from the chain (cobaya yaml, GetDist
.paramnames), then --config, then the raw names.
| Option | Meaning |
|---|---|
-p, --params NAME[,NAME...] |
Parameters to plot, in order (comma-separated and/or repeated) |
-e, --engine |
getdist (default), chainconsumer or anesthetic |
--config FILE |
YAML with truths: {name: value} and labels: {name: latex} |
--latex |
Render raw parameter names as math when the chain has no labels |
-s, --skip |
Fraction of each chain to discard as burn-in (0 ≤ skip < 1) |
Line plots from data files¶
FILE holds whitespace-delimited columns (.txt, .dat) or comma-delimited
.csv; lines starting with # are ignored. Each y column becomes a trace.
# Column 1 against column 0, in a window
cplots lines xy pk.txt --xlabel '$k$' --ylabel '$P(k)$'
# Log-log, saved as PDF
cplots lines xy pk.txt --xscale log --yscale log -o pk.pdf
# Columns 1, 2, 3 as three labelled traces (same as -y 1,2,3)
cplots lines xy data.txt -y 1:4 -l "z=0" -l "z=0.5" -l "z=1"
# PRD single-column figure, interactive HTML with plotly
cplots lines xy pk.txt --paper-format PRD --backend plotly -o fig.html
| Option | Meaning |
|---|---|
-x, --x-col |
0-based column for x (default 0) |
-y, --y-col |
0-based y column(s): 1,2,3 or 1:4 (end exclusive), and/or repeated; default 1 |
-l, --label |
Legend label, one per y column, in order; repeat the flag |
--xlabel, --ylabel |
Axis labels (LaTeX in $...$ works) |
--xscale, --yscale |
linear (default) or log |
Options shared by plot commands¶
| Option | Meaning |
|---|---|
-b, --backend |
matplotlib (default), plotly, altair or ultraplot |
--style |
publication or dark, layered on the default style |
--paper-format |
Journal size and font preset: PRD, PRD-2col, MNRAS, A4 |
-o, --output FILE |
Save the figure; the extension sets the format (.pdf, .png, .svg, .html with plotly) |
--show / --no-show |
Open the figure; shown by default when no --output is given |
Persistent defaults¶
Store values you would otherwise repeat on every command. A flag given on the command line always wins over a stored value.
cplots config set backend plotly
cplots config set paper_format PRD
cplots config get backend # prints the value, or "(not set)"
cplots config unset backend
cplots config show # all settings and the config file location
Keys: backend, engine, theme (the stored name for --style) and
paper_format. Settings live in $XDG_CONFIG_HOME/cplots/config.json
(~/.config/cplots/config.json by default).