Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

add fonts to matplotlib from a particular location

import matplotlib.font_manager as fm
import matplotlib.pyplot as plt

font_path = [path] # font location
newfont = font_manager.findSystemFonts(font_Path) # find fonts
fm.fontManager.addfont(newfont) # add fonts
# then use the newfonts:
plt.rcParams['font.family'] = "newfont"

# Or In the latest matplotlib version > 3.2

font_path = 'Inter-Regular.otf'  # Your font path goes here
fm.fontManager.addfont(font_path)
prop = fm.FontProperties(fname=font_path)
#Use fonts 
plt.rcParams['font.family'] = 'sans-serif'
plt.rcParams['font.sans-serif'] = prop.get_name()
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #add #fonts #matplotlib #location
ADD COMMENT
Topic
Name
7+1 =