Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Forward additional kwargs from sensitivity plot to matplotlib #434

Merged
Prev Previous commit
Next Next commit
API Forward sensitivity plot kwargs to matplotlib
Closes #423

Default drawstyle is steps-post

Related to
- #433 - relying on `drawstyle` over `steps`
- #417 - passing more kwargs to matplotlib plot routines
drewejohnson committed Mar 22, 2021
commit f943d32110859ad8f92d7e527acb73f352ce2f6f
18 changes: 14 additions & 4 deletions serpentTools/parsers/sensitivity.py
Original file line number Diff line number Diff line change
@@ -307,7 +307,7 @@ def _postcheck(self):
def plot(self, resp, zai=None, pert=None, mat=None, mevscale=False,
egrid=None, sigma=3, normalize=True, ax=None, labelFmt=None,
title=None, logx=True, logy=False, loglog=False, xlabel=None,
ylabel=None, legend=None, ncol=1):
ylabel=None, legend=None, ncol=1, **kwargs):
"""
Plot sensitivities due to some or all perturbations.

@@ -358,6 +358,9 @@ def plot(self, resp, zai=None, pert=None, mat=None, mevscale=False,
{ylabel}
{legend}
{ncol}
{kwargs} :method:`matplotlib.pyplot.Axes.errorbar`

.. versionadded: 0.9.4

Returns
-------
@@ -378,7 +381,15 @@ def plot(self, resp, zai=None, pert=None, mat=None, mevscale=False,
if resp not in getattr(self, subDict):
raise KeyError("Response {} missing from {}"
.format(resp, subDict))
labelFmt = labelFmt or "mat: {m} zai: {z} pert: {p}"
if "label" in kwargs:
if labelFmt:
raise ValueError("Passing label= and labelFmt= is not allowed")
labelFmt = kwargs.pop("label")
elif labelFmt is None:
labelFmt = "mat: {m} zai: {z} pert: {p}"

kwargs.setdefault("drawstyle", "steps-post")

if isinstance(zai, (str, int)):
zai = {zai, }
zais = self._getCleanedPertOpt('zais', zai)
@@ -405,8 +416,7 @@ def plot(self, resp, zai=None, pert=None, mat=None, mevscale=False,
yErrs = errors[iM, iZ, iP]
yErrs = hstack((yErrs, yErrs[-1]))
label = labelFmt.format(r=resp, z=z, m=m, p=p)
ax.errorbar(energies, yVals, yErrs, label=label,
drawstyle='steps-post')
ax.errorbar(energies, yVals, yErrs, label=label, **kwargs)

if egrid is not None:
for group in egrid: