Repository: matplotlib/matplotlib
File: lib/matplotlib/stackplot.py (Python)

Code before:
        beginning.

        .. versionadded:: 3.9
           Support for list input

    data : indexable object, optional
        DATA_PARAMETER_PLACEHOLDER

    **kwargs
        All other keyword arguments are passed to `.Axes.fill_between`.  The
            following parameters additionally accept a sequence of values
            corresponding to the *y* datasets:
            *edgecolor(s)*, *facecolor(s)*, *linewidth(s)*, *linestyle(s)*.

            .. versionadded:: 3.11
               Allowing sequences of values in above listed `.Axes.fill_between`
               parameters.

    Returns
    -------
    list of `.PolyCollection`
        A list of `.PolyCollection` instances, one for each element in the
        stacked area plot.
    """

    y = np.vstack(args)

    labels = iter(labels)
    if colors is None:
        colors = [axes._get_lines.get_next_color() for _ in y]

    kwargs['hatch'] = hatch
    kwargs = cbook.normalize_kwargs(kwargs, collections.PolyCollection)
    kwargs.setdefault('facecolor', colors)

    kwargs, style_gen = _style_helpers.style_generator(kwargs)

    # Assume data passed has not been 'stacked', so stack it here.
    # We'll need a float buffer for the upcoming calculations.
    stack = np.cumsum(y, axis=0, dtype=np.promote_types(y.dtype, np.float32))

    _api.check_in_list(['zero', 'sym', 'wiggle', 'weighted_wiggle'],
                       baseline=baseline)
    if baseline == 'zero':
        first_line = 0.

    elif baseline == 'sym':
        first_line = -np.sum(y, 0) * 0.5
        stack += first_line[None, :]

    elif baseline == 'wiggle':

Review comment (suggestion):
Changed this from a generator to a list because `to_rgba_array` needs something with a `__len__`.

Code after:

            - *hatch*
            - *edgecolor*
            - *facecolor*
            - *linewidth*
            - *linestyle*

            .. versionadded:: 3.9
               Allowing a sequence of strings for *hatch*.

            .. versionadded:: 3.11
               Allowing sequences of values in above listed `.Axes.fill_between`
               parameters.

    Returns
    -------
    list of `.PolyCollection`
        A list of `.PolyCollection` instances, one for each element in the
        stacked area plot.
    """

    y = np.vstack(args)

    labels = iter(labels)
    if colors is None:
        colors = [axes._get_lines.get_next_color() for _ in y]

    kwargs = cbook.normalize_kwargs(kwargs, collections.PolyCollection)
    kwargs.setdefault('facecolor', colors)

    kwargs, style_gen = _style_helpers.style_generator(kwargs)

    # Assume data passed has not been 'stacked', so stack it here.
    # We'll need a float buffer for the upcoming calculations.
    stack = np.cumsum(y, axis=0, dtype=np.promote_types(y.dtype, np.float32))

    _api.check_in_list(['zero', 'sym', 'wiggle', 'weighted_wiggle'],
                       baseline=baseline)
    if baseline == 'zero':
        first_line = 0.

    elif baseline == 'sym':
        first_line = -np.sum(y, 0) * 0.5
        stack += first_line[None, :]

    elif baseline == 'wiggle':
        m = y.shape[0]
        first_line = (y * (m - 0.5 - np.arange(m)[:, None])).sum(0)
        first_line /= -m
        stack += first_line