Skip to content

Matplotlib cannot parse TeX with \text command #18520

Closed
@sindzicat

Description

@sindzicat

Hello!

Minimal example:

import matplotlib as plt
fig, ax = plt.subplots()
ax.text(0, 0, r'$s_\text{ind}$')

Result:

ValueError: 
s_\text{ind}
    ^
Expected {accentprefixed | accent | symbol | c_over_c | function | group | frac | dfrac | stackrel | binom | genfrac | sqrt | overline | operatorname}, found 'e'  (at char 4), (line:1, col:5)

As far as I remember, r means raw string, so \t mustn't interpreter as tab. I tried \\t and other ways to avoid this problem but I didn't find any workaround for this case yet... So it seems to me I found a bug.

I use Python 3.8.5 (default, Sep 3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)],
Matplotlib version is 3.3.1. I tried my code in JupyterLab ver. 2.2.7 on Windows 10.
Matplotlib backend is module://ipykernel.pylab.backend_inline.

Best regards,
Sindzicat.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions