fast-plotter

pypi package pipeline status Documentation Status Gitter

To install:

pip install fast-plotter

Or for development:

pip install -e git+https://gitlab.cern.ch/fast-hep/public/fast-plotter.git#egg=fast-plotter
  • Free software: Apache Software License 2.0

Features

  • Functions to turn binned dataframes in the form produced from fast-carpenter
  • A simple command-line tool to produce plots with decent defaults

Command-line Usage

The command-line tools are the primary way to use fast-carpenter and friends at this point. All of the FAST commands provide built-in help by providing the --help option.

fast_plotter

Take a list of fast-carpenter output binned dataframe tables and turns these into plots.

To configure how these plots are made, use either the command-line options, or provide these in a YAML configuration. If an option is provided to both, then the command-line value will take precedence.

$ fast_plotter --help
usage: fast_plotter [-h] [-c CONFIG] [-o OUTDIR] [-e EXTENSION] [-w WEIGHTS]
                    [-d DATA] [-s SIGNAL] [--dataset-col DATASET_COL]
                    [-l LUMI] [-y {log,linear}] [--halt-errors]
                    tables [tables ...]

Turn them tables into plots

positional arguments:
  tables                Table files to process

optional arguments:
  -h, --help            show this help message and exit
  -c CONFIG, --config CONFIG
                        YAML config to control common plotting options
  -o OUTDIR, --outdir OUTDIR
                        Output directory to save plots to
  -e EXTENSION, --extension EXTENSION
                        File extension for images
  -w WEIGHTS, --weights WEIGHTS
                        comma-separated list of weight schemes to plot things
                        for
  -d DATA, --data DATA  Regular expression to identify real data datasets from
                        their name
  -s SIGNAL, --signal SIGNAL
                        Regular expression to identify signal MC datasets from
                        their name
  --dataset-col DATASET_COL
                        Name of column to be used to define multiple-lines for
                        1D plots
  -l LUMI, --lumi LUMI  Scale the MC yields by this lumi
  -y {log,linear}, --yscale {log,linear}
                        Use this scale for the y-axis
  --halt-errors         Stop at the first time an error occurs

The Plotting Config

Use the config file to fine-tune your plots.

Valid options:

Option Default Description
data "data"
Regular expression for values in dataset_col to
plot as scatter markers
weights None Which weight columns to use for plotting.
yscale "linear" Should y-axis be on a linear or a log scale.
lumi 1 Multiply all simulated datasets by this value.
ylabel   Give the Y-axis a title.
legend  
Control the legend placement options. A dictionary of
kwarg pairs passed directly to matplotlib.pyplot.legend()
limits  
Set the axis ranges. Takes a dictionary with x and / or y as
the keys, and a list with upper and lower bounds.
annotations  
Add text to the plot. Should be a list of text labels, each described
by a dictionary containing the text and the position. All
other paramers are passed as keyword-argument pairs to

Todo

Describe the bin_variable_replacements and value_replacements options for the config.

See also

An example of a plotting config cms_public_tutorial demo repository: https://gitlab.cern.ch/fast-hep/public/fast_cms_public_tutorial/blob/master/plot_config.yml

Example repositories

fast_plotter package

Submodules

fast_plotter.interval_from_str module
fast_plotter.interval_from_str.convert_intervals(df, to='mid', level=[], column=[])[source]
fast_plotter.interval_from_str.convert_intervals_column(df, to='mid', select=[])[source]
fast_plotter.interval_from_str.convert_intervals_level(df, to='mid', select=[])[source]
fast_plotter.interval_from_str.interval_from_string(series)[source]
fast_plotter.plotting module
class fast_plotter.plotting.BarColl(n_colors=10, ax=None, fill=True, line=True)[source]

Bases: fast_plotter.plotting.FillColl

class fast_plotter.plotting.FillColl(n_colors=10, ax=None, fill=True, line=True)[source]

Bases: object

pre_call(col)[source]
fast_plotter.plotting.actually_plot(df, x_axis, y, yerr, kind, label, ax, dataset_col='dataset')[source]
fast_plotter.plotting.add_annotations(annotations, ax)[source]
fast_plotter.plotting.pad_zero(x, *y_values)[source]
fast_plotter.plotting.plot_1d(df, kind='line', yscale='lin')[source]
fast_plotter.plotting.plot_1d_many(df, prefix='', data='data', signal=None, dataset_col='dataset', plot_sims='stack', plot_data='sum', plot_signal=None, kind_data='scatter', kind_sims='fill-error-last', kind_signal='line', scale_sims=None, summary='ratio')[source]
fast_plotter.plotting.plot_all(df, project_1d=True, project_2d=True, data='data', signal=None, dataset_col='dataset', yscale='log', lumi=None, annotations=[], dataset_order='sum-ascending', continue_errors=True, bin_variable_replacements={}, **kwargs)[source]
fast_plotter.plotting.plot_ratio(data, sims, x, y, yvar, ax)[source]
fast_plotter.utils module
fast_plotter.utils.interval_from_string(series)[source]
fast_plotter.utils.convert_intervals(df, to='mid', level=[], column=[])[source]

Indices and tables