Repository: matplotlib/matplotlib
File: lib/matplotlib/tests/test_axes.py (Python)

Code before:
    ax_ref = fig_ref.subplots()
    ax_ref.fill_between(x, stack_baseline, y1, hatch="x", facecolor="white")
    ax_ref.fill_between(x, y1, y1+y2, hatch="//", facecolor="white")
    ax_ref.fill_between(x, y1+y2, y1+y2+y3, hatch="\\\\", facecolor="white")
    ax_ref.set_xlim(0, 10)
    ax_ref.set_ylim(0, 70)


def test_stackplot_facecolor():
    # Test that facecolors are properly passed and take precedence over colors parameter
    x = np.linspace(0, 10, 10)
    y1 = 1.0 * x
    y2 = 2.0 * x + 1

    fcols = ['r', 'b']

    fig, ax = plt.subplots()

    colls = ax.stackplot(x, y1, y2, facecolor=fcols, colors=['c', 'm'])
    for coll, fcol in zip(colls, fcols):
        assert mcolors.same_color(coll.get_facecolor(), fcol)

    # Plural alias should also work
    colls = ax.stackplot(x, y1, y2, facecolors=fcols, colors=['c', 'm'])
    for coll, fcol in zip(colls, fcols):
        assert mcolors.same_color(coll.get_facecolor(), fcol)


def test_stackplot_subfig_legend():
    # Smoke test for https://github.com/matplotlib/matplotlib/issues/30158

    fig = plt.figure()
    subfigs = fig.subfigures(nrows=1, ncols=2)

    for _fig in subfigs:
        ax = _fig.subplots(nrows=1, ncols=1)
        ax.stackplot([3, 4], [[1, 2]], labels=['a'])

    fig.legend()
    fig.draw_without_rendering()


def _bxp_test_helper(
        stats_kwargs={}, transform_stats=lambda s: s, bxp_kwargs={}):
    np.random.seed(937)
    logstats = mpl.cbook.boxplot_stats(
        np.random.lognormal(mean=1.25, sigma=1., size=(37, 4)), **stats_kwargs)
    fig, ax = plt.subplots()
    if bxp_kwargs.get('orientation', 'vertical') == 'vertical':
        ax.set_yscale('log')
    else:

Review comment (suggestion):
```suggestion
    facecolors = ['r', 'b']

    fig, ax = plt.subplots()

    colls = ax.stackplot(x, y1, y2, facecolor=facecolors, colors=['c', 'm'])
    for coll, fcol in zip(colls, facecolors):
        assert mcolors.same_color(coll.get_facecolor(), facecolors)

    # Plural alias should also work
    colls = ax.stackplot(x, y1, y2, facecolors=facecolors, colors=['c', 'm'])
    for coll, fcol in zip(colls, facecolors):
        assert mcolors.same_color(coll.get_facecolor(), facecolors)
```
We can affort the additional letters, which IMHO makes this easier to read (In particular, `fcols` is prone to misinterpretation because (1) we have `colls` here and (2) `col(s)` is typically used as abbreviation for *columns*.

Code after:
    ax_ref = fig_ref.subplots()
    ax_ref.fill_between(x, stack_baseline, y1, hatch="x", facecolor="white")
    ax_ref.fill_between(x, y1, y1+y2, hatch="//", facecolor="white")
    ax_ref.fill_between(x, y1+y2, y1+y2+y3, hatch="\\\\", facecolor="white")
    ax_ref.set_xlim(0, 10)
    ax_ref.set_ylim(0, 70)


def test_stackplot_facecolor():
    # Test that facecolors are properly passed and take precedence over colors parameter
    x = np.linspace(0, 10, 10)
    y1 = 1.0 * x
    y2 = 2.0 * x + 1

    facecolors = ['r', 'b']

    fig, ax = plt.subplots()

    colls = ax.stackplot(x, y1, y2, facecolor=facecolors, colors=['c', 'm'])
    for coll, fcolor in zip(colls, facecolors):
        assert mcolors.same_color(coll.get_facecolor(), fcolor)

    # Plural alias should also work
    colls = ax.stackplot(x, y1, y2, facecolors=facecolors, colors=['c', 'm'])
    for coll, fcolor in zip(colls, facecolors):
        assert mcolors.same_color(coll.get_facecolor(), fcolor)


def test_stackplot_subfig_legend():
    # Smoke test for https://github.com/matplotlib/matplotlib/issues/30158

    fig = plt.figure()
    subfigs = fig.subfigures(nrows=1, ncols=2)

    for _fig in subfigs:
        ax = _fig.subplots(nrows=1, ncols=1)
        ax.stackplot([3, 4], [[1, 2]], labels=['a'])

    fig.legend()
    fig.draw_without_rendering()


def _bxp_test_helper(
        stats_kwargs={}, transform_stats=lambda s: s, bxp_kwargs={}):
    np.random.seed(937)
    logstats = mpl.cbook.boxplot_stats(
        np.random.lognormal(mean=1.25, sigma=1., size=(37, 4)), **stats_kwargs)
    fig, ax = plt.subplots()
    if bxp_kwargs.get('orientation', 'vertical') == 'vertical':
        ax.set_yscale('log')
    else: