[Bug]: Qt5Agg icon remains black in dark mode · Issue #30564 · matplotlib/matplotlib · GitHub
Skip to content

[Bug]: Qt5Agg icon remains black in dark mode #30564

Description

@LangQi99

Bug summary

I noticed in a screenshot from another PR that out of the six backends displayed, only the Qt5Agg icon fails to adapt to dark mode. It remains black and blends in with the background, making it difficult to distinguish.

#30554 (comment)

Image

I believe the issue lies in the following code:

if self.palette().color(self.backgroundRole()).value() < 128:
    icon_color = self.palette().color(self.foregroundRole())
    mask = pm.createMaskFromColor(
        QtGui.QColor('black'),
        QtCore.Qt.MaskMode.MaskOutColor)
    pm.fill(icon_color)
    pm.setMask(mask)

It appears the icon is rendered as black regardless of whether the if condition is met. This is likely caused by the line mask = pm.createMaskFromColor(QtGui.QColor('black'), QtCore.Qt.MaskMode.MaskOutColor).

Code for reproduction

import matplotlib
import matplotlib.pyplot as plt
matplotlib.use('Qt5Agg')
fig, ax = plt.subplots(subplot_kw = {"projection" : "3d"})
ax.bar3d([1, 1, 2, 2], [1, 2, 1, 2], 0, 1, 1, [2, 3, 1, 4], axlim_clip=True)
plt.show()

Actual outcome

Image

Expected outcome

Image

Additional information

No response

Operating system

MacOS

Matplotlib Version

3.11.0

Matplotlib Backend

Qt5Agg

Python version

No response

Jupyter version

No response

Installation

None

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions