Quantcast
Viewing all articles
Browse latest Browse all 14069

How to change Matplotlib Style sheets programatically?

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!


Viewing all articles
Browse latest Browse all 14069

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>