通过rcParams选择matplotlibs RectangleSelector的颜色

问题描述 投票:0回答:1

我开发了一个带有pyQt GUI和嵌入式matplotlib画布的Python应用程序()。有一个黑暗和轻盈的主题,通过QSS和rcParams为matplotlib部分选择颜色。但是,矩形选择器在黑暗主题中是不可见的(黑色黑色) - 是否有人知道如何通过rcParams选择其颜色?

使用下面的@AK_S答案,我想从dict中读取设置,例如:

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

但是,我收到错误消息:'toggle_selector.RS' is not a valid rc parameter做的时候

from matplotlib import rcParams
for key in mpl_rc:
    rcParams[key] = mpl_rc[key]
python matplotlib pyqt
1个回答
0
投票

rectprops是您可以使用的属性。

示例代码:

toggle_selector.RS = RectangleSelector(plt.gca(), selected_data,
                               drawtype='box', useblit=True,
                               minspanx=5, minspany=5,
                               spancoords='pixels',
                               interactive=False, rectprops = dict(facecolor='green', edgecolor = 'black', alpha=0.2, fill=True))
© www.soinside.com 2019 - 2024. All rights reserved.