Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
MPL 1.5.1 on Python 3.5 (Anaconda) running on Red Hat 6.5.
This issue is a followup to the discussion on matplotlib-usersCreating Colored Axis Labels using LaTeX in Interactive Mode, which in turn is a followup to Stack OverflowInconsistent rendering of hdashrule in matplotlib axis labels.
In my attempts to get latex colors to show up correctly in axis labels using interactive backends with LaTeX enabled, I came acrosshttp://matplotlib.org/users/pgf.html. I expected to be able to do the following:
import matplotlib as mplfrom matplotlib.backends.backend_pgf import FigureCanvasPgfmatplotlib.backend_bases.register_backend('png', FigureCanvasPgf)from matplotlib import pyplot as pltmatplotlib.rc('pgf', texsystem='pdflatex') # from running latex -vpreamble = matplotlib.rcParams.setdefault('pgf.preamble', [])preamble.append(r'\usepackage{color}')preamble.append(r'\usepackage{dashrule}')ax = plt.plot((0, 1), (1, 2))[0].axesax.set_ylabel(r'Y $\;$ \textcolor[rgb]{1.0, 0.0, 0.0}{\hdashrule[0.5ex]{3cm}{1pt}{1pt 0pt}}')ax.set_xlabel(r'N $\;$ \textcolor[rgb]{0.0, 1.0, 0.0}{\rule[0.5ex]{3cm}{1pt}}')plt.savefig('test.png')
With the default backend, this does not work at all, and the labels are rendered as raw strings containing TeX commands. Withmpl.use('pgf')
, the lines in the labels are rendered black instead of the intended color. Please see the SO question and mailing list discussion for more info.