Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Closed
Labels
Milestone
Description
Bug report
Bug summary
When plotting a Pandas data frame with variables that have underscores in the name, I cannot use theusetex
option without getting an error. Currently,the only solution I can find recommends that I rename the columns in my dataframe to escape special characters, but it seems like there must be a better approach.
Code for reproduction
importpandasaspdimportmatplotlibmatplotlib.rcParams['text.usetex']=Truedf=pd.DataFrame([0,1,2],columns= ["test_column"])df.plot()
Actual outcome
<matplotlib.axes._subplots.AxesSubplot at 0x22a107c4630>---------------------------------------------------------------------------...RuntimeError: latex was not able to process the following string:b'test_column'...! Missing $ inserted.<inserted text> $l.14 ...size{10.000000}{12.500000}{\sffamily test_ column}No pages of output....
Expected outcome
I think it would be good to create an option to easily prevent Latex from interpreting special characters when they appear in data frame column names.
Matplotlib version
- Operating system: Windows 10
- Matplotlib version: 3.1.3
- Matplotlib backend (
print(matplotlib.get_backend())
): Qt5Agg - Python version: 3.6.8
- Jupyter version: Jupyterlab 2.1.4
- Other libraries: Pandas 1.0.1
- Installed with Anaconda