Belle II Software  release-08-01-10
ProfilePlot Class Reference

Public Member Functions

def __init__ (self, x, y, x_axis=None, n_bins=None, label=None)
 
def draw (self, color='black')
 

Public Attributes

 x_axis
 Binning in x.
 
 mean
 Mean of y in bin x.
 
 err
 Std of Mean y in bin x.
 
 label
 Matplotlib label for the plot.
 

Detailed Description

 Basic Profile plot

Creates the profile Histogram from x and y distrinbutions
It plots mean(y) in bins of x

Attributes:
    x_axis (array)  : Binning in x
    mean (array)    : Mean of y in bin x
    err (array)     : Std of Mean y in bin x
    label (string)  : Matplotlib label for the plot

Definition at line 131 of file tools.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  x,
  y,
  x_axis = None,
  n_bins = None,
  label = None 
)
 init function
:param x:       Distribution in x
:param y:       Distribution in y
:param n_bins:  (optional) n bins in x, is set automatically if not provided
:param x_axis:  binning for the x-axis
:param label:   Matplotlib label for the plot

Definition at line 145 of file tools.py.

145  def __init__(self, x, y, x_axis=None, n_bins=None, label=None):
146  """ init function
147  :param x: Distribution in x
148  :param y: Distribution in y
149  :param n_bins: (optional) n bins in x, is set automatically if not provided
150  :param x_axis: binning for the x-axis
151  :param label: Matplotlib label for the plot
152  """
153  if x_axis is None:
154  x_axis = transform.get_optimal_bin_size(len(x))
155  if n_bins is not None:
156  x_axis = n_bins
157 
158 
159  _, self.x_axis = np.histogram(x, x_axis)
160 
161 
162  self.mean = []
163 
164 
165  self.err = []
166 
167 
168  self.label = label
169 
170  # Calculating the Profile histogram
171  for last_x, next_x in zip(self.x_axis[:-1], self.x_axis[1:]):
172  bin_range = (x > last_x) & (x < next_x)
173  n_y_in_bin = len(y[bin_range])
174  if n_y_in_bin == 0:
175  self.mean.append(0)
176  self.err.append(0)
177  else:
178  self.mean.append(np.mean(y[bin_range]))
179  self.err.append(np.sqrt(np.var(y[bin_range]) / n_y_in_bin))
180 

Member Function Documentation

◆ draw()

def draw (   self,
  color = 'black' 
)
 Draw function
:param color: matplotlib color

Definition at line 181 of file tools.py.


The documentation for this class was generated from the following file: