Belle II Software  release-05-01-25
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 125 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 139 of file tools.py.

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

Member Function Documentation

◆ draw()

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

Definition at line 175 of file tools.py.


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