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, x_axis_label=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.
 
 x_axis_label
 x axis label
 

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,
  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
@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, x_axis_label=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
1015 self.x_axis_label = x_axis_label
1016

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

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

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

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.

◆ x_axis_label

x_axis_label

x axis label

Definition at line 1015 of file plotting.py.


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