Belle II Software light-2406-ragdoll
Box Class Reference
Inheritance diagram for Box:
Collaboration diagram for Box:

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 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),
741 # medianprobs=dict(color='blue'),
742 # meanprobs=dict(color='red'),
743 )
744 self.plots.append(p)
745 self.labels.append(column)
746 self.x_axis_label = column
747 r"""
748 self.axis.text(0.1, 0.9, (r'$ \mu = {:.2f}$' + '\n' + r'$median = {:.2f}$').format(x.mean(), x.median()),
749 fontsize=28, verticalalignment='top', horizontalalignment='left', transform=self.axis.transAxes)
750 self.axis.text(0.4, 0.9, (r'$ \sigma = {:.2f}$' + '\n' + r'$IQD = {:.2f}$').format(x.std(),
751 x.quantile(0.75) - x.quantile(0.25)),
752 fontsize=28, verticalalignment='top', horizontalalignment='left', transform=self.axis.transAxes)
753 self.axis.text(0.7, 0.9, (r'$min = {:.2f}$' + '\n' + r'$max = {:.2f}$').format(x.min(), x.max()),
754 fontsize=28, verticalalignment='top', horizontalalignment='left', transform=self.axis.transAxes)
755 """
756
757 return self
758

◆ finish()

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

Reimplemented from Plotter.

Definition at line 759 of file plotting.py.

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

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: