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

Public Member Functions

def __init__ (self, figure=None, axis=None, normed=False, range_in_std=None)
 
def add (self, data, column, mask=None, weight_column=None, label=None)
 
def finish (self)
 

Public Attributes

 normed
 Normalize histograms before drawing them.
 
 range_in_std
 Show only a certain range in terms of standard deviations of the data.
 
 box_axes
 create empty list for box axes
 
 distribution
 The distribution plot.
 

Static Public Attributes

None box_axes = None
 Axes for the boxplots.
 

Detailed Description

Plots distribution of a quantity including boxplots

Definition at line 989 of file plotting.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  figure = None,
  axis = None,
  normed = False,
  range_in_std = 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
@param normed true if the histograms should be normed before drawing
@param range_in_std show only the data in a windows around +- range_in_std * standard_deviation around the mean

Reimplemented from Plotter.

Definition at line 997 of file plotting.py.

997 def __init__(self, figure=None, axis=None, normed=False, range_in_std=None):
998 """
999 Creates a new figure and axis if None is given, sets the default plot parameters
1000 @param figure default draw figure which is used
1001 @param axis default draw axis which is used
1002 @param normed true if the histograms should be normed before drawing
1003 @param range_in_std show only the data in a windows around +- range_in_std * standard_deviation around the mean
1004 """
1005 super().__init__(figure, axis)
1006
1007 self.normed = normed
1008
1009 self.range_in_std = range_in_std
1010
1011 self.box_axes = []
1012
1013 self.distribution = Distribution(self.figure, self.axis, normed_to_all_entries=self.normed, range_in_std=self.range_in_std)
1014

Member Function Documentation

◆ add()

def add (   self,
  data,
  column,
  mask = None,
  weight_column = None,
  label = None 
)
Add a new distribution plot, with additional information like a boxplot compared to
the ordinary Distribution plot.
@param data pandas.DataFrame containing all data
@param column which is used to calculate distribution histogram
@param mask boolean numpy.array defining which events are used for the distribution histogram
@param weight_column column in data containing the weights for each event

Reimplemented from Plotter.

Definition at line 1015 of file plotting.py.

1015 def add(self, data, column, mask=None, weight_column=None, label=None):
1016 """
1017 Add a new distribution plot, with additional information like a boxplot compared to
1018 the ordinary Distribution plot.
1019 @param data pandas.DataFrame containing all data
1020 @param column which is used to calculate distribution histogram
1021 @param mask boolean numpy.array defining which events are used for the distribution histogram
1022 @param weight_column column in data containing the weights for each event
1023 """
1024 self.distribution.set_plot_options(self.plot_kwargs)
1025 self.distribution.set_errorbar_options(self.errorbar_kwargs)
1026 self.distribution.set_errorband_options(self.errorband_kwargs)
1027 self.distribution.add(data, column, mask, weight_column, label=label)
1028
1029 n = len(self.box_axes) + 1
1030 gs = matplotlib.gridspec.GridSpec(4 * n, 1)
1031 gridspecs = [gs[:3 * n, :]] + [gs[3 * n + i, :] for i in range(n)]
1032 box_axis = self.add_subplot(gridspecs)
1033
1034 if self.range_in_std is not None:
1035 mean, std = histogram.weighted_mean_and_std(data[column], None if weight_column is None else data[weight_column])
1036 # Everything outside mean +- range_in_std * std is considered not inside the mask
1037 mask = mask & (data[column] > (mean - self.range_in_std * std)) & (data[column] < (mean + self.range_in_std * std))
1038 box = Box(self.figure, box_axis)
1039 box.add(data, column, mask, weight_column)
1040 if len(box.plots) > 0:
1041 box.plots[0]['boxes'][0].set_facecolor(self.distribution.plots[-1][0][0].get_color())
1042 box.finish()
1043
1044 self.box_axes.append(box_axis)
1045 return self
1046
def weighted_mean_and_std(x, w)
Definition: histogram.py:31

◆ finish()

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

Reimplemented from Plotter.

Definition at line 1047 of file plotting.py.

1047 def finish(self):
1048 """
1049 Sets limits, title, axis-labels and legend of the plot
1050 """
1051 self.distribution.finish()
1052 matplotlib.artist.setp(self.axis.get_xticklabels(), visible=False)
1053 self.axis.get_xaxis().set_label_text('')
1054 for box_axis in self.box_axes[:-1]:
1055 matplotlib.artist.setp(box_axis.get_xticklabels(), visible=False)
1056 box_axis.set_title("")
1057 box_axis.get_xaxis().set_label_text('')
1058 self.box_axes[-1].set_title("")
1059 self.axis.set_title("Distribution Plot")
1060 self.axis.legend([x[0] for x in self.distribution.plots], self.distribution.labels,
1061 loc='best', fancybox=True, framealpha=0.5)
1062 return self
1063
1064

Member Data Documentation

◆ box_axes [1/2]

None box_axes = None
static

Axes for the boxplots.

Definition at line 995 of file plotting.py.

◆ box_axes [2/2]

box_axes

create empty list for box axes

Definition at line 1011 of file plotting.py.

◆ distribution

distribution

The distribution plot.

Definition at line 1013 of file plotting.py.

◆ normed

normed

Normalize histograms before drawing them.

Definition at line 1007 of file plotting.py.

◆ range_in_std

range_in_std

Show only a certain range in terms of standard deviations of the data.

Definition at line 1009 of file plotting.py.


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