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
Matplotlib version 1.5.1
Installed via Anaconda
Issue: When formatting labels (or any text object), one may specify afontdict
dictionary of options. Thisfontdict
supersedes the rcParams and ensures that the text object is always rendered correctly. However, if the text object includes math between dollar signs (i.e.'$a=5$'
) and thematplotlib.mathtext.Parser
is used to render the math, the font-face for the rendered math is specifiable only in the rcParams. This makes it impossible to specify an explicit font face for math within a text object, as whenever that object renders, the math font will always be set by the'mathtext.fontset'
rcParam. This is especially problematic when using matplotlib in interactive mode (i.e. IPython), as every time the text object is rendered, the math font face will change appearance based on the current rcParam value, but all of the other font attributes will continue to be set by the associatedfontdict
.
This may not seem like a big deal, but imagine a developer releases a function to a user that returns a figure object with math in the labels. The developer has chosen to use a sans-serif face for the math, and so changes the rcParams (as this is currently the only handle). Now any future plots the user generates during that interactive session (or in the same script) will silently use the modified rcParam, rather than the users' chosen default, contrary to expectations.
Suggested fix: add amathdict
arg to text objects, which would be analogous to thefontdict
arg, but for all the mathtext rcParams, and pass that to the mathtext parser.