ratio

This module provides the Ratio canvas.

class mATLASplotlib.canvases.ratio.Ratio(shape='square', line_ypos=1.0, **kwargs)

Bases: mATLASplotlib.canvases.base_canvas.BaseCanvas

Ratio canvas with standard ATLAS setup

__init__(shape='square', line_ypos=1.0, **kwargs)

Set up Ratio canvas properties.

Parameters:
  • shape (str) – use either the ‘square’, ‘landscape’ or ‘portrait’ ATLAS proportions
  • line_ypos (float) – where to draw the reference line in the ratio plot
Keyword Arguments:
 

as for BaseCanvas

add_ATLAS_label(x, y, plot_type=None, anchor_to='lower left', fontsize=None, axes=None)

Add an ATLAS label to the canvas at (x, y).

Parameters:
  • x (float) – x position (as a fraction of the canvas width).
  • y (float) – y position (as a fraction of the canvas height).
  • plot_type (str) – Preliminary/Internal/Work-In-Progress/None
  • anchor_to (str) – anchor point (one of the options in location_map).
  • fontsize (float) – font size.
  • axes (str) – which of the different axes in this canvas to use.
add_legend(x, y, anchor_to='lower left', fontsize=None, axes=None)

Add a legend to the canvas at (x, y).

Parameters:
  • x (float) – x position (as a fraction of the canvas width).
  • y (float) – y position (as a fraction of the canvas height).
  • anchor_to (str) – anchor point (one of the options in location_map).
  • fontsize (float) – font size.
  • axes (str) – which of the different axes in this canvas to use.
add_luminosity_label(x, y, sqrts_TeV, luminosity, units='fb-1', anchor_to='lower left', fontsize=14, axes=None)

Add a luminosity label to the canvas at (x, y).

Parameters:
  • x (float) – x position (as a fraction of the canvas width).
  • y (float) – y position (as a fraction of the canvas height).
  • sqrts_TeV (float) – centre-of-mass energy in TeV.
  • luminosity (float) – luminosity.
  • units (str) – luminosity units.
  • anchor_to (str) – anchor point (one of the options in location_map).
  • fontsize (float) – font size.
  • axes (str) – which of the different axes in this canvas to use.
add_text(x, y, text, **kwargs)

Add text to the canvas at (x, y).

Parameters:
  • x (float) – x position (as a fraction of the canvas width).
  • y (float) – y position (as a fraction of the canvas height).
  • text (str) – text to add.
auto_tick_intervals = [0.001, 0.002, 0.0025, 0.004, 0.005, 0.01, 0.02, 0.025, 0.04, 0.05, 0.1, 0.2, 0.25, 0.4, 0.5, 1.0, 2.0, 2.5, 4.0, 5.0]
close()

Close the figure to free up memory. Not needed when this object is used as a context manager.

get_axis_label(axis_name)

Get the label for the chosen axis

Parameters:axis_name (str) – which axis to use.
Returns:axis label
Return type:str
get_axis_range(axis_name)

Get the range for the chosen axis

Parameters:axis_name (str) – which axis to use.
Returns:axis range
Return type:tuple
location_map = {'centre left': ['left', 'center'], 'centre right': ['right', 'center'], 'lower left': ['left', 'bottom'], 'lower right': ['right', 'bottom'], 'upper left': ['left', 'top'], 'upper right': ['right', 'top']}
plot_dataset(*args, **kwargs)

Plot a dataset. Non-keyword arguments will be interpreted as the dataset to be plotted. Keyword arguments will be interpreted as style arguments.

Positional Arguments:
 
  • args: (ROOT.TObject, iterable, numpy array) – plottable information which is passed to Dataset to be interpreted
Keyword Arguments:
 
  • remove_zeros: (bool) – prune any points in the dataset for which the y-value is 0
  • axes: (str) – which axes to use (defaults to the main subplot)
  • style: (str) – which of the plotters in plotters to use
  • label: (str) – label to use in automatic legend generation
  • sort_as: (str) – override
save(output_name, extension='pdf')

Save the current state of the canvas to a file.

Parameters:
  • output_name (str) – name of output file.
  • extension (str or list) – type of output to produce.
set_axis_label(axis_name, axis_label, fontsize=16)

Set the maximum value for the given axis.

Parameters:
  • axis_name (str) – which axis to apply this to.
  • axis_label (str) – desired label.
  • fontsize (float) – font size to use
set_axis_log(axis_names)

Set the specified axis to be on a log-scale.

Parameters:axis_names (str) – which axis (or axes) to apply this to.
set_axis_max(axis_name, maximum)

Set the maximum value for the given axis.

Parameters:
  • axis_name (str) – which axis to apply this to.
  • maximum (float) – desired axis maximum.
set_axis_min(axis_name, minimum)

Set the minimum value for the given axis.

Parameters:
  • axis_name (str) – which axis to apply this to.
  • minimum (float) – desired axis minimum.
set_axis_range(axis_name, axis_range)

Set the range for the given axis.

Parameters:
  • axis_name (str.) – which axis to apply this to.
  • axis_range (iterable) – desired axis range.
set_axis_tick_ndp(axis_name, ndp)

Set number of decimal places to show.

Parameters:
  • axis_name (str) – which axis to apply this to.
  • ndp (int) – how many decimal places to show.
set_axis_ticks(axis_name, ticks)

Set the position of the axis ticks.

Parameters:
  • axis_name (str) – which axis to apply this to.
  • ticks (iterable) – desired tick positions.
set_title(title)

Set the figure title.

Parameters:title (str) – figure title to use
x_tick_label_size

Label size for x-ticks

x_tick_labels

Labels for x-ticks

y_tick_label_size

Label size for y-ticks

y_tick_labels

Labels for y-ticks