Here is the code that produces error, I tried different approaches, but they all throw an error:
from sympy import Matrix, latex
import matplotlib.pyplot as plt
a = Matrix([1, 2])
plt.plot([0, 0], label=latex(a, mode='inline'))
# also produces error
# plt.plot([0, 0], label=f"${latex(a)}$")
# plt.plot([0, 0], label=fr"${latex(a)}$")
plt.legend()