Skip to content

[Bug]: violin's default alpha no longer persists #30613

Closed

Description

@rcomer

Bug summary

Perhaps this is an understood and accepted behaviour change, but I did not see anything in the changenotes. If we set the facecolor of a violin object after creating it, we now also override the default alpha.

Code for reproduction

import matplotlib.pyplot as plt
import numpy as np

fig, ax = plt.subplots()

data = np.random.normal(size=(10, 3))
violins = ax.violinplot(data)

first_violin = violins['bodies'][0]
first_violin.set_facecolor('tab:red')

plt.show()

Actual outcome

With main I get

Image

Expected outcome

With 3.10 I get

Image

Additional information

Bisects to #27304. The default alpha is now included in the default facecolor as a (color, alpha) tuple, rather than being passed by the alpha parameter.

Operating system

Ubuntu

Matplotlib Version

main

Matplotlib Backend

qtagg

Python version

3.13.7

Jupyter version

No response

Installation

git checkout

Activity

  1. added this to the v3.11.0 milestone on Sep 28, 2025
  2. timhoffm commented on Sep 29, 2025

    @timhoffm
    Member

    Oh, this extra tracking of alpha is a nuissance.

    It's tricky to maintain the behavior. Previously, we had facecolor=c, alpha=0.3. We have moved the default alpha into facecolor, because the explicit parameter would overwrite any alpha in user-defined colors. So the only two options are the present change of behavior or you distinguish and set alpha=0.3 only when there are no user-defined colors.

    Without context, I would be inclined to accept the breakage to keep the logic simple. But OTOH your example was the standard way to color violins before, so it is not acceptable to break that.

    Thanks for finding out!

  3. added
    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
    on Sep 29, 2025
  4. added 3 commits that reference this issue on Oct 5, 2025
    3c87254
    520c6c7
    f70a4a2
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

    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions