sciplot package¶
Submodules¶
sciplot.analysis module¶
Analysis tools
-
sciplot.analysis.data_mc_ratio(data, mc, label_data='Data', label_mc='MC', y_label=None, figsize=None, ratio_range=(0, 2), *args, **kwarg)[source]¶ Plot a comparison between two sets of data
Parameters: - data –
- mc –
- label_data –
- label_mc –
- y_label –
- figsize –
- ratio_range –
- *args –
- **kwarg –
Returns:
sciplot.decorations module¶
-
sciplot.decorations.draw_y_label(label='Entries', unit=None, ha='right', *args, **kwargs)[source]¶ Plotting scientific notation y label
Parameters: - label –
- unit –
- ha –
- *args –
- **kwargs –
Returns:
sciplot.functions module¶
In this file all the matplolib wrappers are located.
-
sciplot.functions.errorbar(bin_centers, y, y_err, x_err=None, box=False, plot_zero=True, fmt='.', color=None, ax=None, label=None, *args, **kwargs)[source]¶
-
sciplot.functions.errorhist(data, bins=None, color=None, normed=False, fmt='.', range=None, scale=None, x_err=False, box=False, ax=None, weights=None, plot_zero=True, label=None, *args, **kwargs)[source]¶ Parameters: - data –
- bins –
- color –
- normed –
- fmt –
- range –
- scale –
- x_err –
- box –
- ax –
- weights –
- plot_zero –
- label –
- *args –
- **kwargs –
Returns:
-
sciplot.functions.hist(data, bins=None, fill=False, range=None, lw=1.0, ax=None, style=None, color=None, scale=None, weights=None, label=None, edgecolor=None, *args, **kwargs)[source]¶ Parameters: - data –
- bins –
- fill –
- range –
- lw –
- ax –
- style –
- color –
- scale –
- weights –
- *args –
- **kwargs –
Returns:
-
sciplot.functions.save(filename, bottom=0.15, left=0.13, right=0.96, top=0.95, *args, **kwargs)[source]¶ Save a file and do the subplot_adjust to fit the page with larger labels
Parameters: - filename –
- bottom –
- left –
- right –
- top –
- *args –
- **kwargs –
Returns:
-
sciplot.functions.sig_bkg_plot(df, col, by=None, ax=None, bins=None, range=None, labels=None)[source]¶
-
sciplot.functions.stacked(df, col=None, by=None, bins=None, color=None, range=None, lw=0.5, ax=None, edgecolor='black', *args, **kwargs)[source]¶ Create stacked histogram
Parameters: - df (DataFrame or list of arrays) –
- col –
- by –
- bins –
- color –
- lw –
- *args –
- **kwargs –
Returns:
sciplot.helpers module¶
Helper function and classes are defined here.
-
class
sciplot.helpers.Singleton(decorated)[source]¶ Bases:
objectA non-thread-safe helper class to ease implementing singletons. This should be used as a decorator – not a metaclass – to the class that should be a singleton.
The decorated class can define one __init__ function that takes only the self argument. Other than that, there are no restrictions that apply to the decorated class.
To get the singleton instance, use the Instance method. Trying to use __call__ will result in a TypeError being raised.
Limitations: The decorated class cannot be inherited from.
-
sciplot.helpers.get_optimal_bin_size(n)[source]¶ This function calculates the optimal amount of bins for the number of events n. :param n: number of Events :return: optimal bin size
-
sciplot.helpers.hist2root(h, name=None, title='')[source]¶ Convert your histograms to a root histogram.. if you really want to
Parameters: - h – array with the histogram h=(y_values, bin_edges, (patches=optional))
- name – Name for the root histogram, optional
- title – Title for the root histogram, optional
Returns: TH1F or TH2F depending on the input array
Examples
>>> data = [1,2,3,4,5,6,7] >>> h = b2plot.hist(data) >>> from b2plot.helpers import hist2root >>> root_hist = hist2root(h)
sciplot.skeleton module¶
This is a skeleton file that can serve as a starting point for a Python console script. To run this script uncomment the following lines in the [options.entry_points] section in setup.cfg:
- console_scripts =
- fibonacci = sciplot.skeleton:run
Then run python setup.py install which will install the command fibonacci inside your current environment. Besides console scripts, the header (i.e. until _logger…) of this file can also be used as template for Python modules.
Note: This skeleton file can be safely removed if not needed!
-
sciplot.skeleton.fib(n)[source]¶ Fibonacci example function
Parameters: n (int) – integer Returns: n-th Fibonacci number Return type: int
-
sciplot.skeleton.main(args)[source]¶ Main entry point allowing external calls
Parameters: args ([str]) – command line parameter list
-
sciplot.skeleton.parse_args(args)[source]¶ Parse command line parameters
Parameters: args ([str]) – command line parameters as list of strings Returns: command line parameters namespace Return type: argparse.Namespace