From 13b688c4b28661c4ae397a088eca0a66f41f8df8 Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Mon, 20 Jun 2022 14:39:41 +0100 Subject: [PATCH] feat: title argument added to Corr.show --- pyerrors/correlators.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/pyerrors/correlators.py b/pyerrors/correlators.py index ecb8d525..92e0dd3e 100644 --- a/pyerrors/correlators.py +++ b/pyerrors/correlators.py @@ -731,32 +731,34 @@ class Corr: self.prange = prange return - def show(self, x_range=None, comp=None, y_range=None, logscale=False, plateau=None, fit_res=None, ylabel=None, save=None, auto_gamma=False, hide_sigma=None, references=None): + def show(self, x_range=None, comp=None, y_range=None, logscale=False, plateau=None, fit_res=None, ylabel=None, save=None, auto_gamma=False, hide_sigma=None, references=None, title=None): """Plots the correlator using the tag of the correlator as label if available. Parameters ---------- x_range : list - list of two values, determining the range of the x-axis e.g. [4, 8] + list of two values, determining the range of the x-axis e.g. [4, 8]. comp : Corr or list of Corr Correlator or list of correlators which are plotted for comparison. The tags of these correlators are used as labels if available. logscale : bool - Sets y-axis to logscale + Sets y-axis to logscale. plateau : Obs - Plateau value to be visualized in the figure + Plateau value to be visualized in the figure. fit_res : Fit_result - Fit_result object to be visualized + Fit_result object to be visualized. ylabel : str - Label for the y-axis + Label for the y-axis. save : str - path to file in which the figure should be saved + path to file in which the figure should be saved. auto_gamma : bool Apply the gamma method with standard parameters to all correlators and plateau values before plotting. hide_sigma : float Hides data points from the first value on which is consistent with zero within 'hide_sigma' standard errors. references : list List of floating point values that are displayed as horizontal lines for reference. + title : string + Optional title of the figure. """ if self.N != 1: raise Exception("Correlator must be projected before plotting") @@ -836,6 +838,10 @@ class Corr: handles, labels = ax1.get_legend_handles_labels() if labels: ax1.legend() + + if title: + plt.title(title) + plt.draw() if save: