Skip to content
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

LaTeX axis labels can no longer have custom fonts #6514

Closed
ngoldbaum opened this issue May 31, 2016 · 7 comments
Closed

LaTeX axis labels can no longer have custom fonts #6514

ngoldbaum opened this issue May 31, 2016 · 7 comments
Labels
Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. topic: text
Milestone

Comments

@ngoldbaum
Copy link
Contributor

ngoldbaum commented May 31, 2016

This happens in matplotlib 2.0b1. Here's an example that triggers this behavior:

https://gist.github.com/ngoldbaum/67cf464cc1e2763f95808759423943d9

And this is what the resulting image looks like:

test

Here's what the image produced by the exact same script run under matplotlib 1.5.1 looks like:

test

Note how in matplotlib 1.5.1 the y axis label is drawn using the font I specify in the script (stixgeneral). Under matplotlib 2.0b1, the font is unconditionally set to the default matplotlib font no matter what I do.

This underlying issue is currently causing some labels in yt plots to be rendered with the incorrect font under matplotlib 2.0b1.

@tacaswell tacaswell added this to the 2.0 (style change major release) milestone May 31, 2016
@ngoldbaum
Copy link
Contributor Author

ngoldbaum commented May 31, 2016

Spent a little bit of time digging into matplotlib internals. It's easiest to see a difference by looking at the render_glyph method of the Fonts object, defined in mathtext.py.

Under matplotlib 1.5.1, the call to _get_info inside render_glyph returns a font object with the following filename on my setup:

/Users/goldbaum/Documents/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/cmmi10.ttf

While on matplotlib 2.0b1, it returns a font object with the following filename:

/Users/goldbaum/Documents/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/DejaVuSans-Oblique.ttf

So it looks like the real issue is that mathtext used to be rendered in a serif computer modern font by default, but now defaults to a sans-serif DejaVuSans font.

Is there a way to modify the script I linked to in the issue description to pick out the computer modern font matplotlib used to use?

@ngoldbaum
Copy link
Contributor Author

ping @zblz @mdboom since they appear to be the ones who have worked on these code paths in mathtext.

@ngoldbaum
Copy link
Contributor Author

More precisely, is there a way to set the font used by matplotlib for mathtext rendering using the object-oriented interface? I don't think I can do this by setting rcparams, as suggested in the docs, since this is in the context of a library depending on matplotlib rather a user script making use of matplotlib.

@tacaswell tacaswell added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label May 31, 2016
@ngoldbaum
Copy link
Contributor Author

I'm going to close this and open another issue with a feature request about controlling mathtext fonts via the OO API.

@mdboom
Copy link
Member

mdboom commented Jun 1, 2016

I don't think I can do this by setting rcparams, as suggested in the docs, since this is in the context of a library depending on matplotlib rather a user script making use of matplotlib.

Indeed there's no way other than setting an rcParam at present. You can, however, use the rcParam context manager to change it to what you need and then automatically change it back.

@WeatherGod
Copy link
Member

IIRC, it is possible to pass in a dictionary to the context manager rather
than a style filename... right?

On Wed, Jun 1, 2016 at 8:32 AM, Michael Droettboom <notifications@github.com

wrote:

I don't think I can do this by setting rcparams, as suggested in the docs,
since this is in the context of a library depending on matplotlib rather a
user script making use of matplotlib.

Indeed there's no way other than setting an rcParam at present. You can,
however, use the rcParam context manager to change it to what you need and
then automatically change it back.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#6514 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AARy-B-1wfnG1MzNvqcA0T9HxpkGndk0ks5qHXvqgaJpZM4IquLl
.

@mdboom
Copy link
Member

mdboom commented Jun 1, 2016

@WeatherGod: Yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. topic: text
Projects
None yet
Development

No branches or pull requests

5 participants