Skip to content

[Bug]: Stackplot does not pass facecolor(s) correctly to fill_between #30804

Closed

Description

@rbaardmanWKR

Bug summary

I'm getting an error when specifying facecolor or facecolors for stackplot. Passing color or edgecolor does work however.

Code for reproduction

from matplotlib import pyplot as plt

x = [0, 1, 2]
y = [10, 20, 30]

# Gives error "got multiple values for keyword argument 'facecolor'"
plt.stackplot(x, y, facecolor='red')

# Gives error "Got both 'facecolor' and 'facecolors'"
plt.stackplot(x, y, facecolors='red')

Actual outcome

When specifying facecolor for stackplot, I get the error: "TypeError: matplotlib.axes._axes.Axes.fill_between() got multiple values for keyword argument 'facecolor'".

When specyfing facecolors for stackplot, I get the error: "TypeError: Got both 'facecolor' and 'facecolors', which are aliases of one another".

Expected outcome

It should pass the facecolor(s) to fill_between. How it does that exactly is open for interpretation: I would prefer if it would pass a list of colors as individual colors to subsequent fill_between calls (similar to how stackplot already interprets the color argument)

Additional information

No response

Operating system

macOS 15.7.2

Matplotlib Version

3.9.4

Matplotlib Backend

macosx

Python version

3.9.6

Jupyter version

No response

Installation

pip

Activity

  1. story645 commented on Dec 2, 2025

    @story645
    Member

    I agree with you that it should support face color/facecolors since we document that arguments are pass through.

    Question is should it error out if folks pass color + facecolor or color + edgecolor? Other option is figuring out and communicating an order of precedence, and that seems like asking for confusion.

  2. timhoffm commented on Dec 2, 2025

    @timhoffm
    Member

    Question is should it error out if folks pass color + facecolor or color + edgecolor? Other option is figuring out and communicating an order of precedence, and that seems like asking for confusion.

    Compare what bar() and scatter() do.

  3. story645 commented on Dec 3, 2025

    @story645
    Member

    Compare what bar() and scatter() do.

    They both go w/ facecolor has precedence:

    • bar: If both color and facecolor are given, *facecolor takes precedence.
    • scatter:
      Argument precedence for facecolors:
      - c (if not None)
      - kwargs['facecolor']
      - kwargs['facecolors']
      - kwargs['color'] (==kwcolor)
      - 'b' if in classic mode else the result of ``get_next_color_func()``

    which means that the resolution to this issue is (I think) to add support for facecolor/facecolors to stackplot and handle color+facecolor being passed in together by giving facecolor precedence.

  4. rcomer commented on Dec 3, 2025

    @rcomer
    Member

    This has parallels with #30739. Should we factor out some common style parameter handling for these methods that repeatedly call another method?

  5. added
    API: consistencyConsistency of the matplotlib API, including naming, behavior, defaults, …
    on Dec 3, 2025
  6. rcomer commented on Dec 3, 2025

    @rcomer
    Member

    I have started working on a branch.

  7. added this to the v3.11.0 milestone on Dec 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    API: consistencyConsistency of the matplotlib API, including naming, behavior, defaults, …

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions