Issue
I tried to use mathtext to get a specially rendered figure title, but it failed. Instead of my test title it just printed cryptic characters. What am I doing wrong?
- Operating System: Fedora release 18 (Spherical Cow)
- Python and matplotlib are installed from official repositories via yum
Here's the (full) code:
import sys
print sys.version # prints:
# 2.7.3 (default, Aug 9 2012, 17:23:57)
# [GCC 4.7.1 20120720 (Red Hat 4.7.1-5)]
import matplotlib
print matplotlib.__version__ # prints:
# 1.2.0
import matplotlib.pyplot as plt
plt.plot([1,5])
plt.title(r"$1.2345$")
plt.show()
Here's the output image:
Solution
Apparantly it was a font-related thing. Found an old bug-report to address the issue.
A suggestion in one of the comments was to install the package lyx-fonts
. This solved the problem for me.
Another workaround proposed here is to configure the mathtext rendering like this (at the top of the script):
plt.rcParams['mathtext.fontset'] = "stix"
Answered By - moooeeeep Answer Checked By - Marilyn (WPSolving Volunteer)