Skip to content

Commit

Permalink
plot: adjust pull plots, colors
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesGaessler committed Sep 17, 2024
1 parent 71d18de commit 8472a34
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion kafe2/config/plot_style_color.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ colors:
- &kafe_color1 '#200000' # red-black
# - &kafe_color1 '#403018' # dunkle Kaffeebohne
- &kafe_light_color1 '#E09060' # Latte Macchiato
- &kafe_color2 'navy'
- &kafe_color2 'royalblue'
- &kafe_light_color2 'skyblue'
- &kafe_color3 'darkgreen'
- &kafe_light_color3 'yellowgreen'
Expand Down
20 changes: 13 additions & 7 deletions kafe2/fit/_base/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,14 +643,20 @@ def plot_pull(self, target_axes, error_contributions=("data",), **kwargs):
"""

_xmin, _xmax = self.x_range
target_axes.fill_between([_xmin, _xmax], -2, 2, color=[0.0, 0.0, 0.0, 0.1])
target_axes.fill_between([_xmin, _xmax], -1, 1, color=[0.0, 0.0, 0.0, 0.1])
target_axes.hlines(y=0, xmin=_xmin, xmax=_xmax, colors="black", linestyles=":")
_ymin, _ymax = target_axes.get_ylim()
_pull = (self.data_y - self.model_y) / self._get_total_error(error_contributions)

_yerr = self._get_total_error(error_contributions)
_pull = (self.data_y - self.model_y) / _yerr
_xerr = 0.0125 * (_xmax - _xmin)
# fmt: off
_yerr = np.array([
np.where(_pull < 0, 0, np.abs(_pull)),
np.where(_pull > 0, 0, np.abs(_pull))
])
# fmt: on

return target_axes.errorbar(self.data_x, _pull, xerr=0, yerr=0, **kwargs)
target_axes.hlines(y=0, xmin=_xmin, xmax=_xmax, colors="black", linestyles=":")
kwargs["marker"] = None
return target_axes.errorbar(self.data_x, _pull, xerr=_xerr, yerr=_yerr, **kwargs)

# Overridden by multi plot adapters
def get_formatted_model_function(self, **kwargs):
Expand Down Expand Up @@ -1402,7 +1408,7 @@ def plot(
_axis.set_ylabel(_pull_label)
if pull_range is None:
_plot_adapters = self._get_plot_adapters()[i : i + 1] if self._separate_figs else self._get_plot_adapters()
_max_abs_deviation = 2 # Ensure 1 sigma/2 sigma bands are visible
_max_abs_deviation = 0
for _plot_adapter in _plot_adapters:
_max_abs_deviation = max(
_max_abs_deviation,
Expand Down

0 comments on commit 8472a34

Please sign in to comment.