[Python] Select color of matplotlibs RectangleSelector via rcParams

Discussão em 'Python' iniciado por Stack, Abril 7, 2025.

  1. Stack

    Stack Membro Participativo

    I have developed a Python application () with a pyQt GUI and embedded matplotlib canvases. There is a dark and a light theme where the colors are selected via QSS and rcParams for the matplotlib part. However, the rectangularSelector is invisible in the dark theme (black on black) - does anybody know how to select its color via rcParams?

    Using @AK_S answer below, I'd like to read the settings from a dict, e.g.:

    mpl_rc = {
    'toggle_selector.RS' : {'drawtype': 'box',
    'recttype':dict(
    facecolor='green', edgecolor = 'black', alpha=0.2, fill=True)}
    }


    However, I get the error message: 'toggle_selector.RS' is not a valid rc parameter when doing

    from matplotlib import rcParams
    for key in mpl_rc:
    rcParams[key] = mpl_rc[key]

    Continue reading...

Compartilhe esta Página