Skip to content

[ENH]: Add dark mode for subplot configuration tool #27592

Description

@dstansby

Problem

The subplot configuration tool is currently white background/black text when macOS is in dark mode. It would be nice to apply a dark style sheet when macOS is in dark mode. This is using the macosx backend, but might be an issue for other backends (but not QT AFAIK).

import matplotlib.pyplot as plt
plt.figure()
plt.show()
Screenshot 2024-01-01 at 19 40 19

Proposed solution

Apply a dark style sheet to the configuration tool when macOS is in dark mode.

Activity

  1. timhoffm commented on Jan 1, 2024

    @timhoffm
    Member

    A fundamentally reasonable request. But this applies also to other OS.

    Questions that come to my mind:

    • How do we detect this? platform-specific/cross-platform?
    • Can we inject this into the code path for showing the subplot configuration tool? - It intentionally uses a plot, so that we don't have to implement / maintain this across all backends. So the code path may be platform/backend-agnostic.
    • If we start fiddling with these things, wouldn't it be simpler to (optionally) create native GUI-toolkit versions of the dialog. If the GUI toolkit doesn't provide a the dialog, we fall back to the current figure-based dialog. I anticipate that a native version of this would only be a handful of lines of code, and I don't expect the dialog to change a lot, so the maintainance burden is bearable.
  2. jklymak commented on Jan 1, 2024

    @jklymak
    Member

    The subplot config tool is just a figure isn't it? I guess injecting the right style sheet is a way forward?

  3. timhoffm commented on Jan 2, 2024

    @timhoffm
    Member

    Yes. Subject to my questions above.

  4. anntzer commented on Jan 2, 2024

    @anntzer
    Contributor

    I would say a native tool (such as the one already present for the qt backend) is much more ergonomic.

  5. iccir commented on Jun 30, 2026

    @iccir
    Contributor

    I have a native version of this working. I was focused on keyboard accessibility, but we get dark mode as well:

    Image

    The main question is the ordering of the sliders. qtagg's native tool uses an order of "top", "bottom", "left", "right" / "hspace", "wspace":

    Image

    The figure-based approach uses an order of "left", "bottom", "right", "top", "wspace", "hspace", which matches the positional ordering in matplotlib.pyplot.subplots_adjust:

    Image

    Starting at left and then proceeding anti-clockwise has never made sense to my brain.

    Pairing up top/bottom, left/right, wspace/hspace makes more sense to me. Alternatively: (left,top,right,bottom) would match (x0/y0/x1/y1) found in some UI frameworks. (top,right,bottom,left) matches CSS ordering for shorthand syntax. To me, placing 'wspace' first makes sense if 'left' is first; 'hspace' first if 'top' is first.

    I'm inclined to match the qtagg ordering, but I'm not sure if others have strong opinions on this.

  6. timhoffm commented on Jun 30, 2026

    @timhoffm
    Member

    The order left/bottom/right/top is actually x0/y0/x1/y1 since our figure and Axes coordinate systems start at the bottom left. This is the order of the boundary points in Bbox.

    So formally, this makes sens, but I'm also stumbling over this.

    The point is that this is designed conceptually more as box parameters i.e. absolute coordinates, and not so much as margins. This also means you have left=0.1; right=0.9 for equal margins. Therefore the CSS analogy and order are unfortunately not really applicable (I would have found margins more useful, in particular also because wspace, hspace are distances - but we are not there).

    Overall, I don't have a strong opinion. Either order is fine for me. - And we could even switch later.

  7. iccir commented on Jun 30, 2026

    @iccir
    Contributor

    That probably explains why my brain always hurt when adjusting the subplot :) Truthfully, I would play with the sliders until it looked right.

    Overall, I don't have a strong opinion. Either order is fine for me. - And we could even switch later.

    I coded up the order to be a simple array so re-ordering the rows in the future will be straightforward - no layout code needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions