79834268

Date: 2025-12-01 00:54:25
Score: 0.5
Natty:
Report link

To first answer your question you need to understand the difference between a font-family and a actual font: A font family is a collection of related fonts, like sans-serif, and a font is a specific member of that family, such as Helvetica, Arial, Calibri and the font you are trying to use, Algerian. The font family is the overall design, while the font is the specific variation in weight, style, and size within that design.

Furthermore I spotted this errors in your code:

With this corrections I was able to correct the code to get what I hope is the inted output (didn't understand perfectly the LaTeX issue):

import matplotlib.pyplot as plt

plt.rcParams['font.sans-serif'] = ['Algerian']
plt.rcParams['font.weight'] = 'bold'
plt.rcParams['font.size'] = 10


plt.figure()
plt.text(0.1, 0.5, r"$a*ln(x)*x^2+2$", math_fontfamily='custom')
plt.show()

I found that it needs to be told to use a custom family font to enable a esternal font to be used, the other accepted values are:

'dejavusans', 'dejavuserif', 'cm', 'stix', 'stixsans', 'custom'

this gives in output:enter image description here

which I understand is the one you need.

Some notes:

To further understand how to customise matplotlib refer to the text, labe and annotation docs.

Reasons:
  • Blacklisted phrase (1): enter image description here
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Nimo_17