Belle II Software  release-06-02-00
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 132 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 146 of file tools.py.

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

Member Function Documentation

◆ draw()

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

Definition at line 182 of file tools.py.


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