FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Matplotlib cannot parse TeX with \text command · Issue #18520 · matplotlib/matplotlib · GitHub

Repository navigation

Matplotlib cannot parse TeX with \text command #18520

Closed

Description

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.

Activity

  1. anntzer commented on Sep 18, 2020

    Contributor

    \text is not supported, but I agree that it should be, especially because I think it can just be mapped to \mathdefault; in fact \mathdefault/\mathregular (which are synonyms, and which both only exist in Matplotlib and not in TeX or any(?) package that I know of) could be (soft-)deprecated in favor of \text (which is from the pretty standard amsmath).

  2. sindzicat commented on Sep 18, 2020

    Author

    Sorry, I didn't expect, that there are some TeX commands, that aren't supported in Matplotlib yet. Is there any list of (un)suppoted TeX commands in Matplotlib?

  3. anntzer commented on Sep 18, 2020

    Contributor

    See #14766.

  4. sindzicat commented on Sep 20, 2020

    Author

    @anntzer, many thanks!

  5. tueda commented on Oct 23, 2021

    It will be nice if the \text command can be recognized in Matplotlib. As a first step, \text can be mapped to \mathdefault, but the amsmath \text command keeps spaces in the given text while \mathdefault does not.

  6. oscargus commented on Jan 9, 2022

    Member

    Another issue here (which is maybe more a theoretical issue maybe) is that \text is supposed to use the text font, not the math font. However, I guess it is most commonly used to obtain upright text in math, rather than using the actual text font in equations. At least in the matplotlib context it seems like a fair approximation.

    (One should really need \mathup or something similar to have a family independent, upright font in math mode.)

  7. added this to the v3.8.0 milestone on Mar 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL