Closed Gabriel-p closed 10 months ago
Those warnings are being emitted from matplotlib, and because you are using LaTeX. The underlying cause is what the message says. From SciencePlots, this can't be solved, since this is just a styles package: we do not provide fonts.
You may change your used style to plt.style.use(['science', 'no-latex'])
so that LaTeX errors don't show, or find a way to exclude matplotlib output. I'm not an expert in matplotlib internals nor the logging module, but maybe there are rcParams that deactivate that or some filters that can be applied to the logger, idk.
Hope to have helped you. I'll keep this open although this has nothing to do with SciencePlots. Once you find a solution, please post it to help others.
The issue appears to be triggered by the font.serif : cmr10, Computer Modern Serif, DejaVu Serif
line in science.mplstyle
. This code:
import logging
import matplotlib.pyplot as plt
import matplotlib.pyplot as mpl
mpl.rc('font', family='serif', serif="DejaVu Serif")
mpl.rc('text', usetex=True)
# Set up logging module
level = logging.INFO
frmt = '%(message)s'
handlers = [
logging.FileHandler("test.log", mode='a'),
logging.StreamHandler()]
logging.basicConfig(level=level, format=frmt, handlers=handlers)
fig = plt.figure()
plt.scatter(.5, .5)
plt.xlabel("test label")
plt.savefig("del.png")
produces apparently the same exact output whether I use or not the serif="DejaVu Serif"
argument...
Specified fonts in the following links shouldn't have that problem:
Environment
Describe the issue here
I'm getting dozens of
No LaTeX-compatible font found for the serif fontfamily in rcParams. Using default.
warnings when I try to use thelogging
module along withscienceplots
.How can we reproduce it? What have you tried?
Consider the following minimal example:
In my system this results in:
If I comment the logging block out, the "No-LaTeX..." message goes away.
Extra info
No response