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

FontProperties size and weight ignored by figure.suptitle #6996

Closed
dmkent opened this issue Aug 29, 2016 · 4 comments
Closed

FontProperties size and weight ignored by figure.suptitle #6996

dmkent opened this issue Aug 29, 2016 · 4 comments
Milestone

Comments

@dmkent
Copy link
Contributor

dmkent commented Aug 29, 2016

Passing a FontProperties object to suptitle used to allow setting of font size and weight (in 1.4.*) however #3011 means the defaults from rcParams now override the font properties values.

Issue is somewhere in figure.py#L540.

Happy to put a PR together but not sure on best approach to solve.

Should we check to see if fontproperties is present before overriding? Do other methods handle this somewhere?

This used to work:

from matplotlib import pyplot as plt
from matplotlib.font_manager import FontProperties

fig = plt.figure()
fp = FontProperties(family="sans-serif", size="large", weight="bold")
txt = fig.suptitle('my title', fontproperties=fp)

assert txt.get_weight() == fp.get_weight()
@tacaswell tacaswell added this to the 2.0.1 (next bug fix release) milestone Aug 29, 2016
@tacaswell
Copy link
Member

Sigh, 2 steps forward, one step back.

I think checking if fontproperties is present in the kwargs as well as checking of `fontsize' and 'fontweight' are present is a good solution.

@maksym3d
Copy link

maksym3d commented Sep 1, 2016

Sorry for going off-topic, but while you guys are working on a permanent fix - can you possibly suggest a temporary workaround? We have recently updated matplotlib on our production system and the titles are now all over-sized. Should I just use a text box instead? Thanks!

EDIT: Please never mind. I can use fig.title instead.

@dmkent
Copy link
Contributor Author

dmkent commented Sep 1, 2016

I'm doing this as a workaround:

fig.suptitle("title").set_fontproperties(fp)

Edited: fixed styling after finding back ticks on iOS keyboard...

@maksym3d
Copy link

maksym3d commented Sep 1, 2016

dmkent, thanks for a super quick reply! I tried your workaround and it indeed works! However, I then noticed that when I print a 4-line suptitle, the last line of the text spills under the top edge of the plot. Using fig.title seems to avoid this problem. Go figure.

@QuLogic QuLogic modified the milestones: 2.0 (style change major release), 2.0.1 (next bug fix release) Dec 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants