mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-15 06:40:24 +01:00
plateau feature implemented in Corr.show
This commit is contained in:
parent
7886201983
commit
94cfdd7f66
2 changed files with 11 additions and 4 deletions
|
@ -286,7 +286,7 @@ class Corr:
|
|||
#quick and dirty plotting function to view Correlator inside Jupyter
|
||||
#If one would not want to import pyplot, this could easily be replaced by a call to pe.plot_corrs
|
||||
#This might be a bit more flexible later
|
||||
def show(self, x_range=None, comp=None, logscale=False, save=None):
|
||||
def show(self, x_range=None, comp=None, logscale=False, plateau=None, save=None):
|
||||
"""Plots the correlator, uses tag as label if available.
|
||||
|
||||
Parameters
|
||||
|
@ -322,6 +322,13 @@ class Corr:
|
|||
else:
|
||||
raise Exception('comp must be a correlator or a list of correlators.')
|
||||
|
||||
if plateau:
|
||||
if isinstance(plateau, Obs):
|
||||
ax1.axhline(y=plateau.value, linewidth=2, color=plt.rcParams['text.color'], alpha=0.6, marker=',', ls='--', label='Plateau')
|
||||
ax1.axhspan(plateau.value - plateau.dvalue, plateau.value + plateau.dvalue, alpha=0.25, color=plt.rcParams['text.color'], ls='-')
|
||||
else:
|
||||
raise Exception('plateau must be an Obs')
|
||||
|
||||
ax1.set_xlabel(r'$x_0 / a$')
|
||||
ax1.set_xlim([x_range[0] - 0.5, x_range[1] + 0.5])
|
||||
|
||||
|
|
|
@ -356,7 +356,7 @@ class Obs:
|
|||
plt.ylabel('tauint')
|
||||
length = int(len(self.e_n_tauint[e_name]))
|
||||
plt.errorbar(np.arange(length), self.e_n_tauint[e_name][:], yerr=self.e_n_dtauint[e_name][:], linewidth=1, capsize=2)
|
||||
plt.axvline(x=self.e_windowsize[e_name], color='r', alpha=0.25, marker=',')
|
||||
plt.axvline(x=self.e_windowsize[e_name], color='r', alpha=0.25, marker=',', ls='--')
|
||||
if self.tau_exp[e_name] > 0:
|
||||
base = self.e_n_tauint[e_name][self.e_windowsize[e_name]]
|
||||
x_help = np.arange(2 * self.tau_exp[e_name])
|
||||
|
@ -1180,11 +1180,11 @@ def plot_corrs(observables, **kwargs):
|
|||
if 'plateau' in kwargs:
|
||||
plateau = kwargs.get('plateau')
|
||||
if isinstance(plateau, Obs):
|
||||
plt.axhline(y=plateau.value, linewidth=2, color='k', alpha=0.6, label='Plateau', marker=',')
|
||||
plt.axhline(y=plateau.value, linewidth=2, color='k', alpha=0.6, label='Plateau', marker=',', ls='--')
|
||||
plt.axhspan(plateau.value - plateau.dvalue, plateau.value + plateau.dvalue, alpha=0.25, color='k')
|
||||
elif isinstance(plateau, list):
|
||||
for i in range(len(plateau)):
|
||||
plt.axhline(y=plateau[i].value, linewidth=2, color='C' + str(i), alpha=0.6, label='Plateau' + str(i + 1), marker=',')
|
||||
plt.axhline(y=plateau[i].value, linewidth=2, color='C' + str(i), alpha=0.6, label='Plateau' + str(i + 1), marker=',', ls='--')
|
||||
plt.axhspan(plateau[i].value - plateau[i].dvalue, plateau[i].value + plateau[i].dvalue,
|
||||
color='C' + str(i), alpha=0.25)
|
||||
else:
|
||||
|
|
Loading…
Add table
Reference in a new issue