Belle II Software light-2405-quaxo
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 695 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 702 of file plotting.py.

702 def __init__(self, figure=None, axis=None):
703 """
704 Creates a new figure and axis if None is given, sets the default plot parameters
705 @param figure default draw figure which is used
706 @param axis default draw axis which is used
707 """
708 super().__init__(figure=figure, axis=axis)
709
710
711 self.x_axis_label = ""
712

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

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

◆ finish()

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

Reimplemented from Plotter.

Definition at line 752 of file plotting.py.

752 def finish(self):
753 """
754 Sets limits, title, axis-labels and legend of the plot
755 """
756 matplotlib.artist.setp(self.axis.get_yaxis(), visible=False)
757 self.axis.get_xaxis().set_label_text(self.x_axis_label)
758 self.axis.set_title("Box Plot")
759 return self
760
761

Member Data Documentation

◆ x_axis_label

x_axis_label

Label on x axis.

Definition at line 711 of file plotting.py.


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