Skip to main content
`Ctrl`+`K`

# pandas.api.typing.SeriesGroupBy.hist

SeriesGroupBy.hist(by=None, ax=None, grid=True, xlabelsize=None, xrot=None, ylabelsize=None, yrot=None, figsize=None, bins=10, backend=None, legend=False, **kwargs)

  Draw histogram for each group’s values using `Series.hist()` API.

  A separate histogram subplot is generated for each group, making it easy to visually compare the distribution of values across groups.

  Parameters:
    by object, optional

      Grouping key.

    ax matplotlib.axes.Axes, optional

      Axis to draw the histogram on.

    grid bool, default True

      Show axis grid lines.

    xlabelsize int, default None

      X axis label size.

    xrot float, default None

      Rotation for x ticks.

    ylabelsize int, default None

      Y axis label size.

    yrot float, default None

      Rotation for y ticks.

    figsize tuple, optional

      Figure size in inches.

    bins int or sequence, default 10

      Number of histogram bins or bin edges.

    backend str or callable or None, optional

      Plotting backend to use (e.g. ‘matplotlib’). If None, use the default plotting backend.

    legend bool, default False

      Whether to draw the legend.

    **kwargs

      Additional keyword arguments passed to `Series.hist()`.

  Returns:
    matplotlib.axes.Axes or ndarray of Axes

      The returned matplotlib axes or array of axes depending on input.

  See also

  `Series.hist`

    Equivalent histogram plotting method on Series.

  Examples

      >>> df = pd.DataFrame({"val": [1, 2, 2, 3, 3, 3]}, index=[0, 0, 1, 1, 2, 2])
      >>> g = df["val"].groupby([0, 0, 1, 1, 2, 2])
      >>> g.hist()