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

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

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

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

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

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

Member Data Documentation

◆ box_axes [1/2]

None box_axes = None
static

Axes for the boxplots.

Definition at line 994 of file plotting.py.

◆ box_axes [2/2]

box_axes

create empty list for box axes

Definition at line 1010 of file plotting.py.

◆ distribution

distribution

The distribution plot.

Definition at line 1012 of file plotting.py.

◆ normed

normed

Normalize histograms before drawing them.

Definition at line 1006 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 1008 of file plotting.py.


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