Search code examples
pythonmatplotlibwxpython

Using matplotlib stylesheets with the WXAgg backend


I really like the plots that come out from using the 'ggplot' stylesheet, which is straight forward using pyplot:

import matplotlib.pyplot as plt
plt.style.use('ggplot')
#... plot some stuff ...

However, I'd like to now embed these pretty plots inside of a GUI, using the WXAgg backend. For this, I use:

matplotlib.use('WXAgg')
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
from matplotlib.figure import Figure

Is there any way to use this (or any stylesheet) through the backend? Thanks!


Solution

  • The style module was introduced in v1.4 so you must be using a > 1.4.0.

    The style module is imported into the pyplot namespace for convenience, but can also be directly imported from matplotlib.style with out importing pyplot.