HErmes.plotting package¶
Submodules¶
HErmes.plotting.canvases module¶
Provides canvases for multi axes plots
-
class
HErmes.plotting.canvases.
YStackedCanvas
(subplot_yheights=(0.2, 0.2, 0.5), padding=(0.15, 0.05, 0.0, 0.1), space_between_plots=0, figsize='auto', figure_factory=None)[source]¶ Bases:
object
A canvas for plotting multiple axes
-
eliminate_lower_yticks
()[source]¶ Eliminate the lowest y tick on each axes. The bottom axes keeps its lowest y-tick.
-
global_legend
(*args, **kwargs)[source]¶ A combined legend for all axes
Parameters: args will be passed to pylab.legend (all) – Keyword Arguments: kwargs will be passed to pylab.legend (all) –
-
limit_xrange
(xmin=None, xmax=None)[source]¶ Walk through all axes and set xlims
Keyword Arguments: Returns: None
-
limit_yrange
(ymin=None, ymax=None)[source]¶ Walk through all axes and adjust ymin and ymax
Keyword Arguments: ymin (float) – min ymin value
-
save
(path, name, formats=('pdf', 'png'), **kwargs)[source]¶ Calls pylab.savefig for all endings
Parameters: Keyword Arguments: keyword args will be passed to pylab.savefig (all) –
Returns: The full path to the the saved file
Return type:
-
HErmes.plotting.colors module¶
Color management - provide a nice color scheme even if seaborn is not available
HErmes.plotting.layout module¶
A set of figure sizes for publication-ready figures on A4 paper based on the golden ratio. For the use with pylabe figure, e.g. fig =pylab.figure(figsize=FIGSIZE_A4)
Available layouts:
- FIGSIZE_A4: Figure on full A4 width, portrait mode, golden ratio
- FIGSIZE_A4_LANDSCAPE: Figure on full A4 width, landscape mode, golden ratio
- FIGSIZE_A4_LANDSCAPE_HALF_HEIGHT: Figure on full A4 width, landscape mode, height half of golden ratio
- FIGSIZE_A4_SQUARE: Figure on full A4 width, square
HErmes.plotting.plotting module¶
Define some
-
class
HErmes.plotting.plotting.
VariableDistributionPlot
(cuts=None, color_palette='dark', bins=None, xlabel=None)[source]¶ Bases:
object
A plot which shows the distribution of a certain variable. Cuts can be indicated with lines and arrows. This class defines (and somehow enforces) a certain style.
-
add_cumul
(name)[source]¶ Add a cumulative distribution to the plto
Parameters: name (str) – the name of the category
-
add_cuts
(cut)[source]¶ Add a cut to the the plot which can be indicated by an arrow
Parameters: cuts (HErmes.selection.cuts.Cut) – Returns: None
-
add_data
(variable_data, name, bins=None, weights=None, label='')[source]¶ Histogram the added data and store internally
Parameters: - name (string) – the name of a category
- variable_data (array) – the actual data
Keyword Arguments:
-
add_legend
(**kwargs)[source]¶ Add a legend to the plot. If no kwargs are passed, use some reasonable default.
Keyword Arguments: be passed to pylab.legend (will) –
-
add_ratio
(nominator, denominator, total_ratio=None, total_ratio_errors=None, log=False, label='data/$\\Sigma$ bg')[source]¶ Add a ratio plot to the canvas
Parameters: Keyword Arguments:
-
add_variable
(category, variable_name, external_weights=None, transform=None)[source]¶ Convenience interface if data is sorted in categories already
Parameters: - category (HErmese.variables.category.Category) – Get variable from this category
- variable_name (string) – The name of the variable
Keyword Arguments: - external_weights (np.ndarray) – Supply an array for weighting. This will OVERIDE ANY INTERNAL WEIGHTING MECHANISM and use the supplied weights.
- transform (callable) – Apply transformation todata
-
indicate_cut
(ax, arrow=True)[source]¶ If cuts are given, indicate them by lines
Parameters: ax (pylab.axes) – axes to draw on
-
static
optimal_plotrange_histo
(histograms)[source]¶ Get most suitable x and y limits for a bunc of histograms
Parameters: histograms (list(d.factory.hist1d)) – The histograms in question Returns: xmin, xmax, ymin, ymax Return type: tuple (float, float, float, float)
-
plot
(axes_locator=((0, 'c', 0.2), (1, 'r', 0.2), (2, 'h', 0.5)), combined_distro=True, combined_ratio=True, combined_cumul=True, normalized=True, log=True, legendwidth=1.5, ylabel='rate/bin [1/s]', figure_factory=None)[source]¶ Create the plot
Keyword Arguments: - heights –
- axes_locator –
- combined_distro –
- combined_ratio –
- combined_cumul –
- log –
- normalized (bool) –
Returns:
-
-
HErmes.plotting.plotting.
adjust_minor_ticks
(axis, which='x')[source]¶ Decorate the x-axis with a reasonable set of minor x-ticks
Parameters: axis (matplotlib.axis) – The axis to decorate Keyword Arguments: which (str) – either “x”, “y” or “both” Returns: matplotlib.axis
-
HErmes.plotting.plotting.
create_arrow
(ax, x_0, y_0, dx, dy, length, width=0.1, shape='right', fc='k', ec='k', alpha=1.0, log=False)[source]¶ Create an arrow object for plots. This is typically a large arrow, which can used to indicate a region in the plot which is excluded by a cut.
Parameters: - ax (matplotlib.axes._subplots.AxesSubplot) – The axes where the arrow will be attached to
- x_0 (float) – x-origin of the arrow
- y_0 (float) – y-origin of the arrow
- dx (float) – x length of the arrow
- dy (float) – y length of the arrow
- length (float) – additional scaling parameter to scale the length of the arrow
Keyword Arguments: Returns: matplotlib.axes._subplots.AxesSubplot
-
HErmes.plotting.plotting.
line_plot
(quantities, bins=None, xlabel='', add_ratio=None, ratiolabel='', colors=None, figure_factory=None)[source]¶ Parameters: quantities –
Keyword Arguments: Returns:
-
HErmes.plotting.plotting.
meshgrid
(xs, ys)[source]¶ Create x and y data for matplotlib pcolormesh and similar plotting functions.
Parameters: - xs (np.ndarray) – 1d x bins
- ys (np.ndarray) – 2d y bins
Returns: 2d X and 2d Y matrices as well as a placeholder for the Z array
Return type: tuple (np.ndarray, np.ndarray, np.ndarray)