Skip to content
Snippets Groups Projects
Unverified Commit 1dc9ba2e authored by Frank Sauerburger's avatar Frank Sauerburger
Browse files

Add atlasify() method

Add a method with applies the atlas style and ATLAS badge. This method could be
used to solve #5.
parent 9b4937f7
Branches 59-add-systematic-band-stack
No related tags found
1 merge request!5Resolve "Implement Meta Model"
Pipeline #12376 passed
......@@ -13,6 +13,51 @@ import nnfwtbn.error as err
ATLAS = "Work in Progress"
INFO = "$\sqrt{s} = 13\,\mathrm{TeV}$, $36.1\,\mathrm{fb}^{-1}$\nSome selection"
def atlasify(atlas=False, subtext=None, enlarge=1.3, axes=None):
"""
Applies the atlas style to the plot. If the atlas evaluates to True,
the ATLAS badge is added. If the atlas argument is a non-empty string, the
string is appended after the badge.
If the subtext argument is given, this argument is added on the line
below. The enlarge factor defines how fare the y-axis should be extended
to accommodate for the badge.
If the axes argument is None, the currently active axes is used.
"""
if axes is None:
axes = plt.gca()
ylim = axes.get_ylim()
y_upper = ylim[0] + (ylim[1] - ylim[0]) * enlarge
axes.set_ylim((ylim[0], y_upper))
axes.legend(frameon=False, loc=1)
axes.tick_params("both", which="both", direction="in")
axes.tick_params("both", which="major", length=6)
axes.tick_params("both", which="minor", length=3)
axes.tick_params("x", which="both", top=True)
axes.tick_params("y", which="both", right=True)
axes.xaxis.set_minor_locator(AutoMinorLocator())
axes.yaxis.set_minor_locator(AutoMinorLocator())
y = 0.89
if atlas:
axes.text(0.04, y, "ATLAS", transform=axes.transAxes,
fontdict={"size": 18, "style": "italic", "weight": "bold"})
if isinstance(atlas, str):
axes.text(0.25, y, atlas, transform=axes.transAxes,
fontdict={"size": 12, })
y = 0.86
if isinstance(subtext, str):
axes.text(0.04, y, subtext, transform=axes.transAxes,
fontdict={"size": 12, }, verticalalignment='top')
class HistogramFactory:
"""
Short-cut to create multiple histogram with the same set of processes or
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment