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

define font for plots #1

Open
KatiRG opened this issue Jan 6, 2021 · 2 comments
Open

define font for plots #1

KatiRG opened this issue Jan 6, 2021 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@KatiRG
Copy link
Contributor

KatiRG commented Jan 6, 2021

Using

class font:
    """
    Class defining the global font variables for all functions.
    """
    leg_font = font_manager.FontProperties(family='Libre Franklin',size=9)
    normal = 'Libre Franklin'
    semibold = 'Libre Franklin SemiBold'
    
mpl.rc('font',family='Libre Franklin')    

results in error:
findfont: Font family ['Libre Franklin'] not found. Falling back to DejaVu Sans.

@KatiRG KatiRG added the bug Something isn't working label Jan 6, 2021
@KatiRG KatiRG self-assigned this Jan 6, 2021
@KatiRG
Copy link
Contributor Author

KatiRG commented Jan 6, 2021

Very strange.

Plot font family and fonts can be defined using mpl.rcParams, see here.

e.g.

mpl.rcParams['font.family'] = 'sans-serif'

But, it seems that the above line needs to be run twice to actually work.....

So for now, this line is inside the function, but then before calling the function, I copy this line above the function call so that it runs again.

STRANGE!

@KatiRG
Copy link
Contributor Author

KatiRG commented Jan 6, 2021

About system fonts, you can find which fonts are already installed in your system in this file:

~/.cache/matplotlib/fontlist-v300.json

To install a new font:

Ask an admin to follow this tutorial.

IMPORTANT: Each user needs to remove their font cache (rm -r ~/.cache/matplotlib in the shell) and/or rebuild it with:

import matplotlib.font_manager as font_managerfont_manager._rebuild()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant