-
Notifications
You must be signed in to change notification settings - Fork 730
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
Matplotlib warning about no LaTeX-compatible font. #30
Comments
Hi @arnauqb You got that warning because the given font There are two steps to solve your problem:
|
Hi @garrettj403 The I think that it would be nice to add the free alternatives fonts of Times New Roman like Linux Libertine or Nimbus Roman No. 9 L to the candidate fonts list. Or just adding the solution above to the FAQ section in the The commands to install Times New Roman with different Linux systems are shown below. # Debian / Ubuntu
$ sudo add-apt-repository multiverse && sudo apt update
$ sudo apt install ttf-mscorefonts-installer
# Fedora / CentOS
$ sudo dnf install curl cabextract xorg-x11-font-utils fontconfig
$ sudo rpm -i https://downloads.sourceforge.net/project/mscorefonts2/rpms/msttcore-fonts-installer-2.6-1.noarch.rpm
# Arch Linux
$ yay -S ttf-times-new-roman # Option 1
$ yay -S ttf-ms-fonts # Option 2 Moreover, users can just copy the |
Sorry for the delay, and thank you for your answers. I think that the import matplotlib.pyplot as plt
plt.style.use('science')
plt.rcParams.update({
"font.family": "serif",
"font.serif": ["Times"]}) However, when I switch to I can get around this by using |
Note: I changed the default font in |
Thank you @Hsins for your detailed answer on how to install Times New Roman. I've added a link to this discussion in the README. |
In commit 86e369f, I deleted |
How about using the code below to let
|
The problem is that the Times font causes rendering errors when used in conjunction with Latex math characters. (See my comment above.) I'll see if there is a way around this. |
Thank you very much @Hsins for such detailed responses. However, I'm still facing the same problem, even though Times New Roman is installed (I tested it works in Gedit for instance). It is weird because it seems that the plot is using Times New Roman: and the font name does appear in my Edit: The font is indeed detected by the matplotlib font manager: |
Hi @arnauqb In commit 86e369f, @garrettj403 have changed the font from Would you show that warning message? |
Thanks, I have updated to the last commit and it works fine now. |
This is happening with the latests versions of matplotlib (3.8.1) and SciencePlots (2.1.0).
gives this annoying message multiple times
|
Hi, im encountering the same problem as @marcoBmota8 |
I will have a look at whenever I got time. |
I can't reproduce on Windows neither on Ubuntu.
from pprint import pprint
from matplotlib import get_cachedir
import re
from pathlib import Path
science_fonts = ["cmr10", "Computer Modern Serif", "DejaVu Serif"]
cache_dir = get_cachedir()
print(cache_dir)
font_list_file = Path(cache_dir, "fontlist-v330.json")
assert font_list_file.exists()
for style_font in science_fonts:
regex = re.compile(style_font, re.IGNORECASE)
matched_lines = [line for line in open(font_list_file) if regex.findall(line)]
pprint(matched_lines) |
Hi @echedey-ls This would be the output of the code above
running |
Still need to ensure desired behaviour. Co-Authored-By: Josh Borrow <josh@joshborrow.com>
Co-Authored-By: Josh Borrow <josh@joshborrow.com>
Co-Authored-By: Josh Borrow <josh@joshborrow.com>
Should be solved now in latest release. Upgrade with |
This is still an issue. output from @echedey-ls 's code
|
@marcoBmota8 could you open a new issue and fill all details? Link to this issue if you can. I'll be unable to have a deep look at this for a few months. P.D.: specify the style(s) you are using too. |
Hi,
Whenever I use this package setting
I get the following warning sign multiple times when I plot anything:
Now, I have investigated a little, this warning is issued here:
https://github.com/matplotlib/matplotlib/blob/02af61b3000b93efad98f415b4a7eb330c9e46c1/lib/matplotlib/texmanager.py#L124
so it looks like it cannot found the specified font in the attribute
TexManager.font_info
. I have printed the font that is trying to look at, and it is "Times New Roman", as you would expect, but indeed that font is not found in thefont_info
dictionary:https://github.com/matplotlib/matplotlib/blob/02af61b3000b93efad98f415b4a7eb330c9e46c1/lib/matplotlib/texmanager.py#L62
What am I missing here? I am using:
SciencePlots: latest commite release
Matplotlib: 3.3.0
OS: Manjaro 20.2
Tex: Texlive installation with these packages:
Thank you very much for your help!
The text was updated successfully, but these errors were encountered: