Styling¶
The postprocessing system uses a pattern-based styling system to control the appearance of plots. Styles can be set at the postprocessor level, per-processor, or per-item via transforms.
Style Sets¶
A StyleSet is a list of StyleRule objects.
Each rule has a pattern and a style.
When the postprocessor needs to style a result, it checks each rule in order and uses the first matching style, based on the metadata of the object being processed.
default_style_set:
styles:
- pattern:
dataset_name: 'data*'
style:
plottype: errorbar
color: black
marker: 'o'
- pattern:
dataset_name: 'signal*'
style:
plottype: step
linewidth: 2
- pattern:
sample_type: MC
style:
plottype: fill
Rules are checked in order – put more specific patterns before general ones.
The pattern field uses the same matching system as Pattern Matching.
Style Properties¶
The style object controls how a histogram is rendered.
Generally hese options correspond exactly to the matplotlib function options.
Note though that not every style option will affect every plot.
Property |
Default |
Description |
|---|---|---|
|
|
How to draw the histogram: |
|
auto |
The color. Accepts any matplotlib color string or the CMS palette names (see below). |
|
|
Matplotlib line style: |
|
|
Opacity (0.0 to 1.0). |
|
|
Marker style for errorbar plots. |
|
|
Marker size. |
|
|
Hatch pattern for filled histograms (e.g., |
|
|
Line width override. |
|
|
Whether to show error bars. |
|
|
Whether to show in the legend. |
|
|
Font size for the legend entry. |
|
|
Minimum y-axis value. |
When color is not specified, colors are automatically assigned from the default color cycle.
Plot Types¶
stepA step line (standard histogram outline). This is the default.
fillA filled histogram. Commonly used for stacked MC backgrounds.
errorbarData points with vertical error bars. Commonly used for data.
bandA shaded error band around the histogram.
scatter_zA scatter plot with a color axis. Used for 2D significance scans.
CMS Color Palette¶
The framework includes the official CMS recommended color palette. These can be used by name in style definitions:
Name |
Hex |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
These are registered as named matplotlib colors and can be used directly:
style:
color: cms-blue
Plot Configuration¶
Beyond styles, there are also configuration options that affect the overall appearance and rendering of the plots.
The default_plot_config (or per-processor plot_configuration) controls global plot properties:
default_plot_config:
cms_text: "Preliminary"
image_type: ".png"
cms_text_color: Black
legend_num_cols: 2
Field |
Description |
|---|---|
|
Text shown next to the CMS logo (e.g., “Preliminary”, “Work in Progress”, “Supplementary”). |
|
Output image format: |
|
Color of the CMS text. |
|
Number of columns in the plot legend. |
The framework uses mplhep with the CMS style applied by default.
Additionally, certain options support list values.
If a list is provided, the system will distinct plots, one for each combination of values.
For example, if image_type is [".pdf", ".svg"], the system will produce both a PDF and an SVG file.
Another frequently useful option is to set the cms_text field to ["Preliminary", "Private Work"] to generate plots with different annotations.
Overriding Styles Per-Processor¶
Each processor can have its own style_set that overrides the default:
processors:
- name: Histogram1D
style_set:
styles:
- pattern:
dataset_name: "signal*"
style:
plottype: step
color: cms-red
linewidth: 3
...
If a processor does not specify a style_set, the default_style_set is used.
Overriding Styles Per-Item¶
The SetStyle transform can override the style for specific items within a group:
transforms:
- name: SetStyle
style:
plottype: step
color: blue
should_run:
dataset_name: "signal*"
This is useful when you want fine-grained control over individual items in a plot.