def _check_axes_shape(self, axes, axes_num=None, layout=None, figsize=None): """ Check expected number of axes is drawn in expected layout Parameters ---------- axes : matplotlib Axes object, or its list-like axes_num : number expected number of axes. Unnecessary axes should be set to invisible. layout : tuple expected layout, (expected number of rows , columns) figsize : tuple expected figsize. default is matplotlib default """ if figsize is None: figsize = self.default_figsize visible_axes = self._flatten_visible(axes) if axes_num is not None: self.assertEqual(len(visible_axes), axes_num) for ax in visible_axes: # check something drawn on visible axes self.assertTrue(len(ax.get_children()) > 0) if layout is not None: result = self._get_axes_layout(plotting._flatten(axes)) self.assertEqual(result, layout) self.assert_numpy_array_equal(visible_axes[0].figure.get_size_inches(), np.array(figsize, dtype=np.float64))
def _check_axes_shape(self, axes, axes_num=None, layout=None, figsize=None): """ Check expected number of axes is drawn in expected layout Parameters ---------- axes : matplotlib Axes object, or its list-like axes_num : number expected number of axes. Unnecessary axes should be set to invisible. layout : tuple expected layout, (expected number of rows , columns) figsize : tuple expected figsize. default is matplotlib default """ if figsize is None: figsize = self.default_figsize visible_axes = self._flatten_visible(axes) if axes_num is not None: self.assertEqual(len(visible_axes), axes_num) for ax in visible_axes: # check something drawn on visible axes self.assertTrue(len(ax.get_children()) > 0) if layout is not None: result = self._get_axes_layout(plotting._flatten(axes)) self.assertEqual(result, layout) self.assert_numpy_array_equal( visible_axes[0].figure.get_size_inches(), np.array(figsize, dtype=np.float64))
def _flatten_visible(self, axes): """ Flatten axes, and filter only visible Parameters ---------- axes : matplotlib Axes object, or its list-like """ axes = plotting._flatten(axes) axes = [ax for ax in axes if ax.get_visible()] return axes
def compare_variables(self, cuts= None, **kwargs): # data1: DataFrame # data2: DataFrame # column: string or sequence # If passed, will be used to limit data to a subset of columns if 'alpha' not in self.kwargs: kwargs['alpha'] = 0.5 # if column is not None: # if not isinstance(column, (list, np.ndarray, Index)): # column = [column] # data1 = data1[column] # data2 = data2[column] if cuts != None: if passed_cut (evt, cuts) self.data1 = self.data1._get_numeric_data() self.data2 = self.data2._get_numeric_data() naxes = len(self.data1.columns) fig, axes = plotting._subplots(naxes=naxes, ax=ax, squeeze=False, sharex=sharex, sharey=sharey, figsize=figsize, layout=layout) _axes = plotting._flatten(axes) for i, col in enumerate(com._try_sort(self.data1.columns)): ax = _axes[i] low = min(data1[col].min(), data2[col].min()) high = max(data1[col].max(), data2[col].max()) ax.hist(data1[col].dropna().values, bins=bins, range=(low,high), **kwds) ax.hist(data2[col].dropna().values, bins=bins, range=(low,high), **kwds) ax.set_title(col) ax.grid(grid) plotting._set_ticks_props(axes, xlabelsize=xlabelsize, xrot=xrot, ylabelsize=ylabelsize, yrot=yrot) fig.subplots_adjust(wspace=0.3, hspace=0.7) return axes