Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Cannot make Latex plots when Pandas dataframe has underscore in variable name #17774

Closed
Labels
Milestone
@khof312

Description

@khof312

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp