I get this error while tring to plot some data:
findfont: Font family ['STIXGeneral'] not found. Falling back to DejaVu Sans.
Traceback (most recent call last):
File "F:/Python/compairing-epsilons/main.py", line 71, in <module>
c_1=Bandit.experiment(m1,m2,m3 ,0.1 ,100000)
File "F:/Python/compairing-epsilons/main.py", line 62, in experiment
plt.show()
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\pyplot.py", line 368, in show
return _backend_mod.show(*args, **kwargs)
File "E:\MyProgramFiles\JetBrains\PyCharm 2020.1\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py", line 27, in __call__
manager.show(**kwargs)
File "E:\MyProgramFiles\JetBrains\PyCharm 2020.1\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py", line 99, in show
self.canvas.show()
File "E:\MyProgramFiles\JetBrains\PyCharm 2020.1\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py", line 64, in show
self.figure.tight_layout()
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\figure.py", line 3199, in tight_layout
pad=pad, h_pad=h_pad, w_pad=w_pad, rect=rect)
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\tight_layout.py", line 325, in get_tight_layout_figure
pad=pad, h_pad=h_pad, w_pad=w_pad)
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\tight_layout.py", line 82, in _auto_adjust_subplotpars
bb = [ax.get_tightbbox(renderer, for_layout_only=True)]
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\axes\_base.py", line 4620, in get_tightbbox
renderer, for_layout_only=for_layout_only)
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\axis.py", line 1105, in get_tightbbox
self._update_label_position(renderer)
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\axis.py", line 2083, in _update_label_position
bboxes, bboxes2 = self._get_tick_boxes_siblings(renderer=renderer)
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\axis.py", line 1881, in _get_tick_boxes_siblings
tlb, tlb2 = axis._get_tick_bboxes(ticks_to_draw, renderer)
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\axis.py", line 1086, in _get_tick_bboxes
for tick in ticks if tick.label1.get_visible()],
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\axis.py", line 1086, in <listcomp>
for tick in ticks if tick.label1.get_visible()],
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\text.py", line 910, in get_window_extent
bbox, info, descent = self._get_layout(self._renderer)
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\text.py", line 318, in _get_layout
clean_line, self._fontproperties, ismath=ismath)
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\backends\backend_agg.py", line 265, in get_text_width_height_descent
self.mathtext_parser.parse(s, self.dpi, prop)
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\mathtext.py", line 435, in parse
return self._parse_cached(s, dpi, prop, _force_standard_ps_fonts)
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\mathtext.py", line 447, in _parse_cached
font_output = fontset_class(prop, backend)
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\_mathtext.py", line 577, in __init__
self.cm_fallback = StixSansFonts(*args, **kwargs)
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\_mathtext.py", line 681, in __init__
fullpath = findfont(name)
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\font_manager.py", line 1309, in findfont
rc_params)
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\font_manager.py", line 1362, in _findfont_cached
fallback_to_default=False)
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\font_manager.py", line 1309, in findfont
rc_params)
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\font_manager.py", line 1364, in _findfont_cached
raise ValueError(f"Failed to find font {prop}, and fallback "
ValueError: Failed to find font DejaVu Sans:style=normal:variant=normal:weight=normal:stretch=normal:size=10.0, and fallback to the default font was disabled
Process finished with exit code 1
I don't get this font error for my other project while plotting. how can solve error?
CodePudding user response:
Based on this github issue try deleting everything in the cache directory of matplotlib
import matplotlib
print(matplotlib.get_cachedir()) # should return something like ~/.matplotlib
Navigate to that directory and delete the fonts file, which will be something like fontlist-v330.json