tex font cannot be used in matplotlib after import pyOPAL
There seems to be an issue with adding tex symbols in matplotlib after import pyOPAL. The simple code snippet below
from matplotlib import rc
from opal.opal import load_dataset
import matplotlib.pyplot as plt
FontSize=22
FontSizeLabelAxis=22
rc('xtick',labelsize=FontSize)
rc('ytick',labelsize=FontSize)
rc('text', usetex=True)
x=np.linspace(-10,10,100)
plt.plot (x,x**2)
plt.xlabel (r'$x$ ')
give the error
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-4-11cccf49f543> in <module>
14 x=np.linspace(-10,10,100)
15 plt.plot (x,x**2)
---> 16 plt.xlabel (r'$x$ ')
/usr/lib64/python3.9/site-packages/matplotlib/pyplot.py in xlabel(xlabel, fontdict, labelpad, loc, **kwargs)
3113 @_copy_docstring_and_deprecators(Axes.set_xlabel)
3114 def xlabel(xlabel, fontdict=None, labelpad=None, *, loc=None, **kwargs):
-> 3115 return gca().set_xlabel(
3116 xlabel, fontdict=fontdict, labelpad=labelpad, loc=loc,
3117 **kwargs)
/usr/lib64/python3.9/site-packages/matplotlib/axes/_axes.py in set_xlabel(self, xlabel, fontdict, labelpad, loc, **kwargs)
245 elif loc == 'right':
246 kwargs.update(x=1, horizontalalignment='right')
--> 247 return self.xaxis.set_label_text(xlabel, fontdict, **kwargs)
248
249 def get_ylabel(self):
/usr/local/lib/python3.9/site-packages/opal-1.0.0-py3.9.egg/opal/utilities/wrapper.py in run(*args, **kwargs)
35 @functools.wraps(fun)
36 def run(*args, **kwargs):
---> 37 return new_fun(fun, *args, **kwargs)
38 return run
39
/usr/local/lib/python3.9/site-packages/opal-1.0.0-py3.9.egg/opal/utilities/wrapper.py in new_label(fun, *args, **kwargs)
67 # we need to add the signs otherwise LaTex formulas
68 # are not properly compiled
---> 69 re._alphanum_str = re._alphanum_str.union(signs)
70 lst[idx] = re.escape(lst[idx])
71 # remove signs again
AttributeError: module 're' has no attribute '_alphanum_str'