return self
def _mainplot(self, ax):
// to make the stacked violin plots, the
// `ax` is subdivided horizontally and in each horizontal sub ax
// a seaborn violin plot is added.
// work on a copy of the dataframes. This is to avoid changes
// on the original data frames after repetitive calls to the
// StackedViolin object, for example once with swap_axes and other without
_matrix = self.obs_tidy.copy()
if self.var_names_idx_order is not None:
_matrix = _matrix.iloc[:, self.var_names_idx_order]
if self.categories_order is not None:
_matrix.index = _matrix.index.reorder_categories(
self.categories_order, ordered=True
)
// get mean values for color and transform to color values
// using colormap
_color_df = _matrix.groupby(level=0).median()
if self.are_axes_swapped:
_color_df = _color_df.T
cmap = pl.get_cmap(self.kwds.get("cmap", self.cmap))
if "cmap" in self.kwds:
del self.kwds["cmap"]
normalize = check_colornorm(
self.vboundnorm.vmin,
self.vboundnorm.vmax,
self.vboundnorm.vcenter,
self.vboundnorm.norm,
)
colormap_array = cmap(normalize(_color_df.values))
x_spacer_size = self.plot_x_padding
y_spacer_size = self.plot_y_padding
self._make_rows_of_violinplots(