Erroneous fetching of Minion Pro font for matplotlib plotting

Following the accepted answer of this thread, I’m trying to use the following MinionPro-Regular otf font installed on my Windows 10 machine

enter image description here

to set the fonts of all texts and math expressions of my plot to that font as follows.

import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np

mpl.rcParams['font.family'] = 'MinionPro-Regular'
mpl.rc('text', usetex='true') 
mpl.rc('text.latex', preamble=r'usepackage{bm}')

x = np.arange(0,2*np.pi,0.1)
y = np.sin(x)

fig, ax = plt.subplots()
ax.plot(x,y, label ='Exact')
ax.set_xlabel(r"$bm{x}$", fontsize=20)
ax.xaxis.label.set_color('red')
ax.set_ylabel(r"$bm{y}$", fontsize=20)
ax.yaxis.label.set_color('red')
ax.set_title("My title", size=20)

plt.legend()
plt.show()

However, I get the error below:

findfont: Font family ['MinionPro-Regular'] not found. Falling back to DejaVu Sans.

Any idea regarding this problem?

Edit: if I use mpl.rcParams['font.family'] = 'Minion Pro', there is no error, however the font is still not Minion Pro like:

enter image description here

Answer

Check out site-packages/matplotlib/mpl-data/matplotlibrc. Apparently, font.family is “not supported when rendering text with usetex“.

From the text.usetex documentation,

The following fonts are supported through the usual rc parameter settings: new century schoolbook, bookman, times, palatino, zapf chancery, charter, serif, sans-serif, helvetica, avant garde, courier, monospace, computer modern roman, computer modern sans serif, computer modern typewriter. If another font is desired which can loaded using the LaTeX usepackage command, please inquire at the Matplotlib mailing list“.