Issue
I know there is a way to TeX inside the legend, but it doesn't understand arguments such as a line break or the matrix environment. I haven't been able to find any other resources that address drawing out a small matrix inside the legend itself, or even overlaying the matrix onto the plot. This is the best I can get:
with this code:
plt.plot(perturbation, errors,label=r'$A=[ 3 2 ][ 4 3 ]$')
plt.legend(loc='upper left', prop={'size': 12})
Thanks for any suggestions!
Solution
For me it works
In [7]: import numpy as np
...: import matplotlib
...: matplotlib.rcParams['text.usetex'] = True
...: import matplotlib.pyplot as plt
...: t = np.linspace(0.0, 1.0, 100)
...: s = np.cos(4 * np.pi * t) + 2
...:
...: fig, ax = plt.subplots(figsize=(6, 4), tight_layout=True)
...: ax.plot(t, s)
...:
...: ax.set_xlabel(r'$\left[\matrix{ 1 & 0 \cr 0 & 1 }\right]$')
Out[7]: Text(0.5, 0, '$\\left[\\matrix{ 1 & 0 \\cr 0 & 1 }\\right]$')
Answered By - gboffi
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.