I'm trying to change/toggle between two available matplotlib styles, "dark_background" & "classic", based on user feedback through a gui button status. I tried using plt.style.use("dark_background")
and plt.style.use("classic")
to change matplotlib styles during runtime but it is not working.
however, plt.style.use("dark_background")
and plt.style.use("classic")
work fine when they are set in a Matplotlib class init function:
class MatplotlibWidget(QWidget): def __init__(self, parent=None): super(MatplotlibWidget, self).__init__(parent) self.style = "Dark" plt.style.use("dark_background") # plt.style.use("yammiXLightTheme")
here is code snipet for the button call back function where i'm trying to change style programatically:
def change_style(self): if self.style == "Dark": plt.style.use("classic") self.style = "Light" else: plt.style.use("dark_background") self.style = "Dark" self.canvas.draw()
thanks in advance for your help!