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

Changing the font type #460

Open
ryansohny opened this issue Jul 26, 2023 · 6 comments
Open

Changing the font type #460

ryansohny opened this issue Jul 26, 2023 · 6 comments

Comments

@ryansohny
Copy link

Hi, thank you for this amazing and super-light tool.

I'm using pyGenomeTracks version 3.8 and I'm wondering if I can change the font type, say from default font type into Arial type.

Thank you.
Sohn

@lldelisle
Copy link
Collaborator

For the moment we cannot.
But this feature should not be difficult to implement.
To myself:
This would be a new argument to the command line and we would use it here:

font = {'size': fontsize}
matplotlib.rc('font', **font)

I think the parameter should be font.family: https://matplotlib.org/stable/tutorials/text/text_props.html#default-font

@ryansohny, you can check which are the font.families available on your computer by running:

python -c "import matplotlib.font_manager;print(matplotlib.font_manager.get_font_names())"

@ryansohny
Copy link
Author

Thanks for the quick and thoughful reply, Delisle.
I managed to change the font in the figure, following your advice.

#In tracksClass.py line 330:
font = {'size': fontsize, 'family': 'arial'} #Added 'family' key

Thank you again

Best regards
Sohn

@lldelisle
Copy link
Collaborator

I will keep it open until I implemented it as it is a good idea of improvement

@lldelisle lldelisle reopened this Jul 26, 2023
@rikrdo89
Copy link

I have pgt installed through conda, and when changing the fonts as @ryansohny suggested, I got this error:
matplotlib.font_manager:findfont: Font family 'arial' not found

Any ideas how we can import the arial font type?

@ryansohny
Copy link
Author

Ricardo, I would first install mscorefonts in that virtual environment though anaconda. And then if that doesn’t work out either, I think you need to delete your matpltlib json file.

Linux: rm ~/.cache/matplotlib/fontlist*.json
M1 mac: rm ~/Library/Caches/matplotlib/fontlist*.json

Hope for the best

@rikrdo89
Copy link

thanks a lot, that solved my issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants