Ejemplo n.º 1
0
    def _violinplot(
        self,
        data: dataType,
        names: namesType,
        title: titleType = None,
        ax: matplotlib.axes.SubplotBase = None,
    ) -> matplotlib.figure.Figure:
        """For making violinplots."""

        if ax is None:
            _, ax = plt.subplots()
        else:
            ax = ax

        figure = ax.get_figure()
        width = max(self.num_players / 3, 12)
        height = width / 2
        spacing = 4
        positions = spacing * arange(1, self.num_players + 1, 1)
        figure.set_size_inches(width, height)
        ax.violinplot(
            data,
            positions=positions,
            widths=spacing / 2,
            showmedians=True,
            showextrema=False,
        )
        ax.set_xticks(positions)
        ax.set_xticklabels(names, rotation=90)
        ax.set_xlim([0, spacing * (self.num_players + 1)])
        ax.tick_params(axis="both", which="both", labelsize=8)
        if title:
            ax.set_title(title)
        plt.tight_layout()
        return figure
Ejemplo n.º 2
0
    def _violinplot(
            self,
            data: dataType,
            names: namesType,
            title: titleType = None,
            ax: matplotlib.axes.SubplotBase = None
    ) -> matplotlib.figure.Figure:
        """For making violinplots."""

        if ax is None:
            _, ax = plt.subplots()
        else:
            ax = ax

        figure = ax.get_figure()
        width = max(self.nplayers / 3, 12)
        height = width / 2
        spacing = 4
        positions = spacing * arange(1, self.nplayers + 1, 1)
        figure.set_size_inches(width, height)
        ax.violinplot(data,
                      positions=positions,
                      widths=spacing / 2,
                      showmedians=True,
                      showextrema=False)
        ax.set_xticks(positions)
        ax.set_xticklabels(names, rotation=90)
        ax.set_xlim([0, spacing * (self.nplayers + 1)])
        ax.tick_params(axis='both', which='both', labelsize=8)
        if title:
            ax.set_title(title)
        plt.tight_layout()
        return figure
Ejemplo n.º 3
0
 def plot_2_2(ax: matplotlib.axes.SubplotBase, df_eff_k: pd.DataFrame, rows_set: np.ndarray) -> None:
     lty = ["--", "-", "--"]
     lwd = [1, 2, 1]
     mu, sigma = ClusteringUtils.calc_distribution(df_eff_k.loc[rows_set])
     y = pd.DataFrame([mu - sigma, mu, mu + sigma]).transpose()
     for col in y.columns:
         ax.plot(df_eff_k.columns, y[col], color="red", linestyle=lty[col], linewidth=lwd[col])
         ax.set_xlabel("k")
         ax.set_ylabel("effective k")
         ax.set_xlim(1, df_eff_k.columns.max())
         ax.set_ylim(1, df_eff_k.columns.max())
     abline_vals = np.array(ax.get_xlim())
     ax.plot(abline_vals, abline_vals, color="grey", linestyle="--")