Ejemplo n.º 1
0
    def plot_group(keys, values, ax: Axes, **kwds):
        # GH 45465: xlabel/ylabel need to be popped out before plotting happens
        xlabel, ylabel = kwds.pop("xlabel", None), kwds.pop("ylabel", None)
        if xlabel:
            ax.set_xlabel(pprint_thing(xlabel))
        if ylabel:
            ax.set_ylabel(pprint_thing(ylabel))

        keys = [pprint_thing(x) for x in keys]
        values = [np.asarray(remove_na_arraylike(v), dtype=object) for v in values]
        bp = ax.boxplot(values, **kwds)
        if fontsize is not None:
            ax.tick_params(axis="both", labelsize=fontsize)

        # GH 45465: x/y are flipped when "vert" changes
        is_vertical = kwds.get("vert", True)
        ticks = ax.get_xticks() if is_vertical else ax.get_yticks()
        if len(ticks) != len(keys):
            i, remainder = divmod(len(ticks), len(keys))
            assert remainder == 0, remainder
            keys *= i
        if is_vertical:
            ax.set_xticklabels(keys, rotation=rot)
        else:
            ax.set_yticklabels(keys, rotation=rot)
        maybe_color_bp(bp, **kwds)

        # Return axes in multiplot case, maybe revisit later # 985
        if return_type == "dict":
            return bp
        elif return_type == "both":
            return BoxPlot.BP(ax=ax, lines=bp)
        else:
            return ax
Ejemplo n.º 2
0
    def plot_group(keys, values, ax: Axes):
        keys = [pprint_thing(x) for x in keys]
        values = [
            np.asarray(remove_na_arraylike(v), dtype=object) for v in values
        ]
        bp = ax.boxplot(values, **kwds)
        if fontsize is not None:
            ax.tick_params(axis="both", labelsize=fontsize)
        if kwds.get("vert", 1):
            ticks = ax.get_xticks()
            if len(ticks) != len(keys):
                i, remainder = divmod(len(ticks), len(keys))
                assert remainder == 0, remainder
                keys *= i
            ax.set_xticklabels(keys, rotation=rot)
        else:
            ax.set_yticklabels(keys, rotation=rot)
        maybe_color_bp(bp, **kwds)

        # Return axes in multiplot case, maybe revisit later # 985
        if return_type == "dict":
            return bp
        elif return_type == "both":
            return BoxPlot.BP(ax=ax, lines=bp)
        else:
            return ax
Ejemplo n.º 3
0
 def __draw_box_plot(
     axes: Axes,
     change_coordinates: List[Tuple[int, int, int]],
     title: str,
 ) -> None:
     added_dict, modified_dict, renamed_dict, total_dict = (
         dict(),
         dict(),
         dict(),
         dict(),
     )
     for commit_x, count_y, type_c in change_coordinates:
         added_dict.setdefault(commit_x, 0)
         modified_dict.setdefault(commit_x, 0)
         renamed_dict.setdefault(commit_x, 0)
         total_dict.setdefault(commit_x, 0)
         if type_c == 1:
             added_dict[commit_x] = count_y
         elif type_c == 2:
             modified_dict[commit_x] = count_y
         elif type_c == 3:
             renamed_dict[commit_x] = count_y
         else:
             continue
         total_dict[commit_x] += count_y
     added = [count for count in added_dict.values()]
     modified = [count for count in modified_dict.values()]
     renamed = [count for count in renamed_dict.values()]
     total = [count for count in total_dict.values()]
     axes.set_title(title)
     axes.boxplot(
         x=[added, modified, renamed, total],
         labels=("added", "modified", "renamed", "total"),
         showfliers=False,
     )
     return None