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

Public Member Functions

def __init__ (self, figure=None, axis=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 702 of file plotting.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  figure = None,
  axis = 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 709 of file plotting.py.

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

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 720 of file plotting.py.

720 def add(self, data, column, mask=None, weight_column=None):
721 """
722 Add a new boxplot to the plots
723 @param data pandas.DataFrame containing all data
724 @param column which is used to calculate boxplot quantities
725 @param mask boolean numpy.array defining which events are used for the histogram
726 @param weight_column column in data containing the weights for each event
727 """
728 if mask is None:
729 mask = numpy.ones(len(data)).astype('bool')
730 x = data[column][mask]
731 if weight_column is not None:
732 # weight = data[weight_column][mask]
733 b2.B2WARNING("Weights are currently not used in boxplot, due to limitations in matplotlib")
734
735 if len(x) == 0:
736 b2.B2WARNING("Ignore empty boxplot.")
737 return self
738
739 # we don't plot outliers as they cause the file size to explode if large datasets are used
740 p = self.axis.boxplot(x, sym='k.', whis=1.5, vert=False, patch_artist=True, showmeans=True, widths=1,
741 boxprops=dict(facecolor='blue', alpha=0.5), showfliers=False,
742 # medianprobs=dict(color='blue'),
743 # meanprobs=dict(color='red'),
744 )
745 self.plots.append(p)
746 self.labels.append(column)
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 718 of file plotting.py.


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