I am using matplotlib version 2.0.0 on Python 3 in a miniconda virtual environment. I am working on a unix scientific computing cluster where I don't have root privileges. I am generally executing python code through an ipython notebook. If I do a basic command such as:
import matplotlib.pyplot as plt
plt.scatter([1,5], [1,5])
I get an error message:
path_to_miniconda/miniconda3/envs/conda34/lib/python3.4/site-
packages/matplotlib/font_manager.py:1297: UserWarning: findfont: Font family
['sans-serif'] not found. Falling back to DejaVu Sans
(prop.get_family(), self.defaultFamily[fontext]))
I would like to be able to use a Times New Roman font but even after deleting the Font cache file (fontList.py3k.cache) which I find from here:
import matplotlib as mpl
fm = mpl.font_manager
fm.get_cachedir()
The commands:
mpl.rcParams['font.family'] = ['serif']
mpl.rcParams['font.serif'] = ['Times New Roman']
have no effect, I get the same error as above. The true type fonts directory:
path_to_miniconda/miniconda3/envs/conda34/lib/python3.4/site-packages/matplotlib/mpl-data/fonts/ttf/
only has 40 fonts in it of the type: DejaVuSerif,DejaVuSans,STIX,cmb, cmt, cmy
Any idea what could be going on and how I can add additional fonts? Thanks!
I am using matplotlib version 2.0.0 on Python 3 in a miniconda virtual environment. I am working on a unix scientific computing cluster where I don't have root privileges. I am generally executing python code through an ipython notebook. If I do a basic command such as:
import matplotlib.pyplot as plt
plt.scatter([1,5], [1,5])
I get an error message:
path_to_miniconda/miniconda3/envs/conda34/lib/python3.4/site-
packages/matplotlib/font_manager.py:1297: UserWarning: findfont: Font family
['sans-serif'] not found. Falling back to DejaVu Sans
(prop.get_family(), self.defaultFamily[fontext]))
I would like to be able to use a Times New Roman font but even after deleting the Font cache file (fontList.py3k.cache) which I find from here:
import matplotlib as mpl
fm = mpl.font_manager
fm.get_cachedir()
The commands:
mpl.rcParams['font.family'] = ['serif']
mpl.rcParams['font.serif'] = ['Times New Roman']
have no effect, I get the same error as above. The true type fonts directory:
path_to_miniconda/miniconda3/envs/conda34/lib/python3.4/site-packages/matplotlib/mpl-data/fonts/ttf/
only has 40 fonts in it of the type: DejaVuSerif,DejaVuSans,STIX,cmb, cmt, cmy
Any idea what could be going on and how I can add additional fonts? Thanks!
I am using matplotlib version 2.0.0 on Python 3 in a miniconda virtual environment. I am working on a unix scientific computing cluster where I don't have root privileges. I am generally executing python code through an ipython notebook. If I do a basic command such as:
import matplotlib.pyplot as plt
plt.scatter([1,5], [1,5])
I get an error message:
path_to_miniconda/miniconda3/envs/conda34/lib/python3.4/site-
packages/matplotlib/font_manager.py:1297: UserWarning: findfont: Font family
['sans-serif'] not found. Falling back to DejaVu Sans
(prop.get_family(), self.defaultFamily[fontext]))
I would like to be able to use a Times New Roman font but even after deleting the Font cache file (fontList.py3k.cache) which I find from here:
import matplotlib as mpl
fm = mpl.font_manager
fm.get_cachedir()
The commands:
mpl.rcParams['font.family'] = ['serif']
mpl.rcParams['font.serif'] = ['Times New Roman']
have no effect, I get the same error as above. The true type fonts directory:
path_to_miniconda/miniconda3/envs/conda34/lib/python3.4/site-packages/matplotlib/mpl-data/fonts/ttf/
only has 40 fonts in it of the type: DejaVuSerif,DejaVuSans,STIX,cmb, cmt, cmy
Any idea what could be going on and how I can add additional fonts? Thanks!
I am using matplotlib version 2.0.0 on Python 3 in a miniconda virtual environment. I am working on a unix scientific computing cluster where I don't have root privileges. I am generally executing python code through an ipython notebook. If I do a basic command such as:
import matplotlib.pyplot as plt
plt.scatter([1,5], [1,5])
I get an error message:
path_to_miniconda/miniconda3/envs/conda34/lib/python3.4/site-
packages/matplotlib/font_manager.py:1297: UserWarning: findfont: Font family
['sans-serif'] not found. Falling back to DejaVu Sans
(prop.get_family(), self.defaultFamily[fontext]))
I would like to be able to use a Times New Roman font but even after deleting the Font cache file (fontList.py3k.cache) which I find from here:
import matplotlib as mpl
fm = mpl.font_manager
fm.get_cachedir()
The commands:
mpl.rcParams['font.family'] = ['serif']
mpl.rcParams['font.serif'] = ['Times New Roman']
have no effect, I get the same error as above. The true type fonts directory:
path_to_miniconda/miniconda3/envs/conda34/lib/python3.4/site-packages/matplotlib/mpl-data/fonts/ttf/
only has 40 fonts in it of the type: DejaVuSerif,DejaVuSans,STIX,cmb, cmt, cmy
Any idea what could be going on and how I can add additional fonts? Thanks!
I am using matplotlib version 2.0.0 on Python 3 in a miniconda virtual environment. I am working on a unix scientific computing cluster where I don't have root privileges. I am generally executing python code through an ipython notebook. If I do a basic command such as:
import matplotlib.pyplot as plt
plt.scatter([1,5], [1,5])
I get an error message:
path_to_miniconda/miniconda3/envs/conda34/lib/python3.4/site-
packages/matplotlib/font_manager.py:1297: UserWarning: findfont: Font family
['sans-serif'] not found. Falling back to DejaVu Sans
(prop.get_family(), self.defaultFamily[fontext]))
I would like to be able to use a Times New Roman font but even after deleting the Font cache file (fontList.py3k.cache) which I find from here:
import matplotlib as mpl
fm = mpl.font_manager
fm.get_cachedir()
The commands:
mpl.rcParams['font.family'] = ['serif']
mpl.rcParams['font.serif'] = ['Times New Roman']
have no effect, I get the same error as above. The true type fonts directory:
path_to_miniconda/miniconda3/envs/conda34/lib/python3.4/site-packages/matplotlib/mpl-data/fonts/ttf/
only has 40 fonts in it of the type: DejaVuSerif,DejaVuSans,STIX,cmb, cmt, cmy
Any idea what could be going on and how I can add additional fonts? Thanks!
I am using matplotlib version 2.0.0 on Python 3 in a miniconda virtual environment. I am working on a unix scientific computing cluster where I don't have root privileges. I am generally executing python code through an ipython notebook. If I do a basic command such as:
import matplotlib.pyplot as plt
plt.scatter([1,5], [1,5])
I get an error message:
path_to_miniconda/miniconda3/envs/conda34/lib/python3.4/site-
packages/matplotlib/font_manager.py:1297: UserWarning: findfont: Font family
['sans-serif'] not found. Falling back to DejaVu Sans
(prop.get_family(), self.defaultFamily[fontext]))
I would like to be able to use a Times New Roman font but even after deleting the Font cache file (fontList.py3k.cache) which I find from here:
import matplotlib as mpl
fm = mpl.font_manager
fm.get_cachedir()
The commands:
mpl.rcParams['font.family'] = ['serif']
mpl.rcParams['font.serif'] = ['Times New Roman']
have no effect, I get the same error as above. The true type fonts directory:
path_to_miniconda/miniconda3/envs/conda34/lib/python3.4/site-packages/matplotlib/mpl-data/fonts/ttf/
only has 40 fonts in it of the type: DejaVuSerif,DejaVuSans,STIX,cmb, cmt, cmy
Any idea what could be going on and how I can add additional fonts? Thanks!
I am using matplotlib version 2.0.0 on Python 3 in a miniconda virtual environment. I am working on a unix scientific computing cluster where I don't have root privileges. I am generally executing python code through an ipython notebook. If I do a basic command such as:
import matplotlib.pyplot as plt
plt.scatter([1,5], [1,5])
I get an error message:
path_to_miniconda/miniconda3/envs/conda34/lib/python3.4/site-
packages/matplotlib/font_manager.py:1297: UserWarning: findfont: Font family
['sans-serif'] not found. Falling back to DejaVu Sans
(prop.get_family(), self.defaultFamily[fontext]))
I would like to be able to use a Times New Roman font but even after deleting the Font cache file (fontList.py3k.cache) which I find from here:
import matplotlib as mpl
fm = mpl.font_manager
fm.get_cachedir()
The commands:
mpl.rcParams['font.family'] = ['serif']
mpl.rcParams['font.serif'] = ['Times New Roman']
have no effect, I get the same error as above. The true type fonts directory:
path_to_miniconda/miniconda3/envs/conda34/lib/python3.4/site-packages/matplotlib/mpl-data/fonts/ttf/
only has 40 fonts in it of the type: DejaVuSerif,DejaVuSans,STIX,cmb, cmt, cmy
Any idea what could be going on and how I can add additional fonts? Thanks!
I am using matplotlib version 2.0.0 on Python 3 in a miniconda virtual environment. I am working on a unix scientific computing cluster where I don't have root privileges. I am generally executing python code through an ipython notebook. If I do a basic command such as:
import matplotlib.pyplot as plt
plt.scatter([1,5], [1,5])
I get an error message:
path_to_miniconda/miniconda3/envs/conda34/lib/python3.4/site-
packages/matplotlib/font_manager.py:1297: UserWarning: findfont: Font family
['sans-serif'] not found. Falling back to DejaVu Sans
(prop.get_family(), self.defaultFamily[fontext]))
I would like to be able to use a Times New Roman font but even after deleting the Font cache file (fontList.py3k.cache) which I find from here:
import matplotlib as mpl
fm = mpl.font_manager
fm.get_cachedir()
The commands:
mpl.rcParams['font.family'] = ['serif']
mpl.rcParams['font.serif'] = ['Times New Roman']
have no effect, I get the same error as above. The true type fonts directory:
path_to_miniconda/miniconda3/envs/conda34/lib/python3.4/site-packages/matplotlib/mpl-data/fonts/ttf/
only has 40 fonts in it of the type: DejaVuSerif,DejaVuSans,STIX,cmb, cmt, cmy
Any idea what could be going on and how I can add additional fonts? Thanks!
I am using matplotlib version 2.0.0 on Python 3 in a miniconda virtual environment. I am working on a unix scientific computing cluster where I don't have root privileges. I am generally executing python code through an ipython notebook. If I do a basic command such as:
import matplotlib.pyplot as plt
plt.scatter([1,5], [1,5])
I get an error message:
path_to_miniconda/miniconda3/envs/conda34/lib/python3.4/site-
packages/matplotlib/font_manager.py:1297: UserWarning: findfont: Font family
['sans-serif'] not found. Falling back to DejaVu Sans
(prop.get_family(), self.defaultFamily[fontext]))
I would like to be able to use a Times New Roman font but even after deleting the Font cache file (fontList.py3k.cache) which I find from here:
import matplotlib as mpl
fm = mpl.font_manager
fm.get_cachedir()
The commands:
mpl.rcParams['font.family'] = ['serif']
mpl.rcParams['font.serif'] = ['Times New Roman']
have no effect, I get the same error as above. The true type fonts directory:
path_to_miniconda/miniconda3/envs/conda34/lib/python3.4/site-packages/matplotlib/mpl-data/fonts/ttf/
only has 40 fonts in it of the type: DejaVuSerif,DejaVuSans,STIX,cmb, cmt, cmy
Any idea what could be going on and how I can add additional fonts? Thanks!
I am using matplotlib version 2.0.0 on Python 3 in a miniconda virtual environment. I am working on a unix scientific computing cluster where I don't have root privileges. I am generally executing python code through an ipython notebook. If I do a basic command such as:
import matplotlib.pyplot as plt
plt.scatter([1,5], [1,5])
I get an error message:
path_to_miniconda/miniconda3/envs/conda34/lib/python3.4/site-
packages/matplotlib/font_manager.py:1297: UserWarning: findfont: Font family
['sans-serif'] not found. Falling back to DejaVu Sans
(prop.get_family(), self.defaultFamily[fontext]))
I would like to be able to use a Times New Roman font but even after deleting the Font cache file (fontList.py3k.cache) which I find from here:
import matplotlib as mpl
fm = mpl.font_manager
fm.get_cachedir()
The commands:
mpl.rcParams['font.family'] = ['serif']
mpl.rcParams['font.serif'] = ['Times New Roman']
have no effect, I get the same error as above. The true type fonts directory:
path_to_miniconda/miniconda3/envs/conda34/lib/python3.4/site-packages/matplotlib/mpl-data/fonts/ttf/
only has 40 fonts in it of the type: DejaVuSerif,DejaVuSans,STIX,cmb, cmt, cmy
Any idea what could be going on and how I can add additional fonts? Thanks!
I am using matplotlib version 2.0.0 on Python 3 in a miniconda virtual environment. I am working on a unix scientific computing cluster where I don't have root privileges. I am generally executing python code through an ipython notebook. If I do a basic command such as:
import matplotlib.pyplot as plt
plt.scatter([1,5], [1,5])
I get an error message:
path_to_miniconda/miniconda3/envs/conda34/lib/python3.4/site-
packages/matplotlib/font_manager.py:1297: UserWarning: findfont: Font family
['sans-serif'] not found. Falling back to DejaVu Sans
(prop.get_family(), self.defaultFamily[fontext]))
I would like to be able to use a Times New Roman font but even after deleting the Font cache file (fontList.py3k.cache) which I find from here:
import matplotlib as mpl
fm = mpl.font_manager
fm.get_cachedir()
The commands:
mpl.rcParams['font.family'] = ['serif']
mpl.rcParams['font.serif'] = ['Times New Roman']
have no effect, I get the same error as above. The true type fonts directory:
path_to_miniconda/miniconda3/envs/conda34/lib/python3.4/site-packages/matplotlib/mpl-data/fonts/ttf/
only has 40 fonts in it of the type: DejaVuSerif,DejaVuSans,STIX,cmb, cmt, cmy
Any idea what could be going on and how I can add additional fonts? Thanks!
I fixed it by setting pyplot parameter:
import matplotlib.pyplot as plt
plt.rcParams['font.family'] = 'serif'
so you can use fonts (Helvetica, Times New Roman) like the following:
ax.set_title('your_title_text',fontname="Times New Roman", fontsize=20)
I am using matplotlib version 2.0.0 on Python 3 in a miniconda virtual environment. I am working on a unix scientific computing cluster where I don't have root privileges. I am generally executing python code through an ipython notebook. If I do a basic command such as:
import matplotlib.pyplot as plt
plt.scatter([1,5], [1,5])
I get an error message:
path_to_miniconda/miniconda3/envs/conda34/lib/python3.4/site-
packages/matplotlib/font_manager.py:1297: UserWarning: findfont: Font family
['sans-serif'] not found. Falling back to DejaVu Sans
(prop.get_family(), self.defaultFamily[fontext]))
I would like to be able to use a Times New Roman font but even after deleting the Font cache file (fontList.py3k.cache) which I find from here:
import matplotlib as mpl
fm = mpl.font_manager
fm.get_cachedir()
The commands:
mpl.rcParams['font.family'] = ['serif']
mpl.rcParams['font.serif'] = ['Times New Roman']
have no effect, I get the same error as above. The true type fonts directory:
path_to_miniconda/miniconda3/envs/conda34/lib/python3.4/site-packages/matplotlib/mpl-data/fonts/ttf/
only has 40 fonts in it of the type: DejaVuSerif,DejaVuSans,STIX,cmb, cmt, cmy
Any idea what could be going on and how I can add additional fonts? Thanks!
I am using matplotlib version 2.0.0 on Python 3 in a miniconda virtual environment. I am working on a unix scientific computing cluster where I don't have root privileges. I am generally executing python code through an ipython notebook. If I do a basic command such as:
import matplotlib.pyplot as plt
plt.scatter([1,5], [1,5])
I get an error message:
path_to_miniconda/miniconda3/envs/conda34/lib/python3.4/site-
packages/matplotlib/font_manager.py:1297: UserWarning: findfont: Font family
['sans-serif'] not found. Falling back to DejaVu Sans
(prop.get_family(), self.defaultFamily[fontext]))
I would like to be able to use a Times New Roman font but even after deleting the Font cache file (fontList.py3k.cache) which I find from here:
import matplotlib as mpl
fm = mpl.font_manager
fm.get_cachedir()
The commands:
mpl.rcParams['font.family'] = ['serif']
mpl.rcParams['font.serif'] = ['Times New Roman']
have no effect, I get the same error as above. The true type fonts directory:
path_to_miniconda/miniconda3/envs/conda34/lib/python3.4/site-packages/matplotlib/mpl-data/fonts/ttf/
only has 40 fonts in it of the type: DejaVuSerif,DejaVuSans,STIX,cmb, cmt, cmy
Any idea what could be going on and how I can add additional fonts? Thanks!
None of the above worked for me. I had to combine the provided solutions.
I run Jupyter from PyCharm in Windows 10 . Here is my workaround. Before doing these steps, import the font manager via import matplotlib.font_manager
:
matplotlib.font_manager.findSystemFonts(fontpaths=None, fontext='ttf')
matplotlib.matplotlib_fname()
pdf.fonttype: 42 # Output Type 3 (Type3) or Type 42 (TrueType)
\matplotlib\__pycache__
folder.plt.rcParams['font.family'] = 'serif'
plt.rcParams['font.serif'] = ['Lin Libertine']
If you restart your kernel, if will generate cache files, hence you need to remove them again.
My situation is that I have JupyterHub running in Docker and I need to use matplotlib
to plot and display some Chinese characters as titles.
Here's how I install new fonts and get new fonts worked( No need to restart the Jupyter container ):
Docker Image version:
matplotlib.__version__
: 3.1.2 All operations are executed inside the container.
download the fonts to /.../python3.7/site-packages/matplotlib/mpl-data/fonts/ttf
rebuild the font cache in a notebook. ~/.cache/matplotlib/
( AttributeError: module 'matplotlib' has no attribute 'font_manager' ).
import matplotlib.font_manager
matplotlib.font_manager._rebuild()
the font cache is per-user base( /home/{username}/.cache/matplotlib/
), so other people might need to rebuild the cache too.
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['SimSun']
You might need to restart the notebook/kernel in step 2 and 3.
Notes:
I tried sudo apt install msttcorefonts -qq
but I don't think that works. Neither do I know what has been installed by that package. apt-file list msttcorefonts
returns nothing.
Why apt-file list msttcorefonts
returns nothing?
There is a configuration file /.../python3.7/site-packages/matplotlib/mpl-data/matplotlibrc
on which one can add font.sans-serif
fonts. But without modifying it, the new fonts also work.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.