1"""
2===============================
3A mathtext image as numpy array
4===============================
5
6Make images from LaTeX strings.
7"""
8
9import matplotlib.mathtext as mathtext
10import matplotlib.pyplot as plt
11import matplotlib
12matplotlib.rc('image', origin='upper')
13
14parser = mathtext.MathTextParser("Bitmap")
15parser.to_png('test2.png',
16              r'$\left[\left\lfloor\frac{5}{\frac{\left(3\right)}{4}} '
17              r'y\right)\right]$', color='green', fontsize=14, dpi=100)
18
19rgba1, depth1 = parser.to_rgba(
20    r'IQ: $\sigma_i=15$', color='blue', fontsize=20, dpi=200)
21rgba2, depth2 = parser.to_rgba(
22    r'some other string', color='red', fontsize=20, dpi=200)
23
24fig = plt.figure()
25fig.figimage(rgba1, 100, 100)
26fig.figimage(rgba2, 100, 300)
27
28plt.show()
29