Belle II Software development
Box Class Reference
Inheritance diagram for Box:
Plotter

Public Member Functions

def __init__ (self, figure=None, axis=None, x_axis_label=None)
 
def add (self, data, column, mask=None, weight_column=None)
 
def finish (self)
 

Public Attributes

 x_axis_label
 Label on x axis.
 

Detailed Description

Create a boxplot

Definition at line 701 of file plotting.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  figure = None,
  axis = None,
  x_axis_label = None 
)
Creates a new figure and axis if None is given, sets the default plot parameters
@param figure default draw figure which is used
@param axis default draw axis which is used

Reimplemented from Plotter.

Definition at line 708 of file plotting.py.

708 def __init__(self, figure=None, axis=None, x_axis_label=None):
709 """
710 Creates a new figure and axis if None is given, sets the default plot parameters
711 @param figure default draw figure which is used
712 @param axis default draw axis which is used
713 """
714 super().__init__(figure=figure, axis=axis)
715
716
717 self.x_axis_label = x_axis_label
718

Member Function Documentation

◆ add()

def add (   self,
  data,
  column,
  mask = None,
  weight_column = None 
)
Add a new boxplot to the plots
@param data pandas.DataFrame containing all data
@param column which is used to calculate boxplot quantities
@param mask boolean numpy.array defining which events are used for the histogram
@param weight_column column in data containing the weights for each event

Reimplemented from Plotter.

Definition at line 719 of file plotting.py.

719 def add(self, data, column, mask=None, weight_column=None):
720 """
721 Add a new boxplot to the plots
722 @param data pandas.DataFrame containing all data
723 @param column which is used to calculate boxplot quantities
724 @param mask boolean numpy.array defining which events are used for the histogram
725 @param weight_column column in data containing the weights for each event
726 """
727 if mask is None:
728 mask = numpy.ones(len(data)).astype('bool')
729 x = data[column][mask]
730 if weight_column is not None:
731 # weight = data[weight_column][mask]
732 b2.B2WARNING("Weights are currently not used in boxplot, due to limitations in matplotlib")
733
734 if len(x) == 0:
735 b2.B2WARNING("Ignore empty boxplot.")
736 return self
737
738 # we don't plot outliers as they cause the file size to explode if large datasets are used
739 p = self.axis.boxplot(x, sym='k.', whis=1.5, vert=False, patch_artist=True, showmeans=True, widths=1,
740 boxprops=dict(facecolor='blue', alpha=0.5), showfliers=False,
741 # medianprobs=dict(color='blue'),
742 # meanprobs=dict(color='red'),
743 )
744 self.plots.append(p)
745 self.labels.append(column)
746 if not self.x_axis_label:
747 self.x_axis_label = column
748 r"""
749 self.axis.text(0.1, 0.9, (r'$ \mu = {:.2f}$' + '\n' + r'$median = {:.2f}$').format(x.mean(), x.median()),
750 fontsize=28, verticalalignment='top', horizontalalignment='left', transform=self.axis.transAxes)
751 self.axis.text(0.4, 0.9, (r'$ \sigma = {:.2f}$' + '\n' + r'$IQD = {:.2f}$').format(x.std(),
752 x.quantile(0.75) - x.quantile(0.25)),
753 fontsize=28, verticalalignment='top', horizontalalignment='left', transform=self.axis.transAxes)
754 self.axis.text(0.7, 0.9, (r'$min = {:.2f}$' + '\n' + r'$max = {:.2f}$').format(x.min(), x.max()),
755 fontsize=28, verticalalignment='top', horizontalalignment='left', transform=self.axis.transAxes)
756 """
757
758 return self
759

◆ finish()

def finish (   self)
Sets limits, title, axis-labels and legend of the plot

Reimplemented from Plotter.

Definition at line 760 of file plotting.py.

760 def finish(self):
761 """
762 Sets limits, title, axis-labels and legend of the plot
763 """
764 matplotlib.artist.setp(self.axis.get_yaxis(), visible=False)
765 self.axis.get_xaxis().set_label_text(self.x_axis_label)
766 self.axis.set_title("Box Plot")
767 return self
768
769

Member Data Documentation

◆ x_axis_label

x_axis_label

Label on x axis.

Definition at line 717 of file plotting.py.


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