-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Feature request: set mathtext fonts via the object oriented API #6518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Can this be achieved with an
I agree it would be nice for a way to set both text and mathtext fonts as a group so they are consistent, and currently it is not completely obvious.with mpl.rc_context(fname='mpl.rc', rc={'text.usetex': True}): edit: nevermind, I saw you already mentioned the context manager in the email. |
While it's true that this issue can be dealt with using a context manager (ping @mdboom and @WeatherGod, let's move discussion to this issue since it has a clearer call for action), I think that's less useful than being able to programmatically customize fonts using the Here's a couple reasons to justify why I want something besides the context manager approach:
|
The tricky bit here is that math rendering requires a particular set of fonts that work together (the "fontset") rather than a single font. There are only a very small set of such fontsets supported. So we'd need to add a new property to |
That actually sounds nice to me - I could do: fp = FontProperties(**{'family': 'stixgeneral', 'mathtext-fontset': 'cmr'}) And non-mathtext text will use 'stixgeneral', while mathtext uses computer modern. |
I'll be +1 to that idea, but I get the point that it isn't ideal. As a On Wed, Jun 1, 2016 at 1:28 PM, ngoldbaum notifications@github.com wrote:
|
A possible alternative would be to set However, in the case specified by @ngoldbaum ( |
On 2016/06/01 10:51 PM, Victor Zabalza wrote:
Looking at surrounding text? That sounds much too complicated and magical. |
Closed by #18145. |
As far as I can see (and according to the documentation), the only way to set the font of mathtext snippets in plots is via the mathtext.fontset rcparam.
It would be nice if there were some way to control the fonts used for mathtext rendering without messing with the rcparams system. Maybe the font could be chosen based on the
FontProperties
instance associated with the Text object? To make a concrete example, it would be nice if the y label for this plot were rendered using a serif font, like the rest of the plot.For additional context, see #6514 and my message to the matplotlib-devel mailing list: https://mail.python.org/pipermail/matplotlib-devel/2016-May/000454.html
The text was updated successfully, but these errors were encountered: