Skip to content

Inconsistent handling of whitespace with LaTeX #4954

Closed as not planned
Closed as not planned

Description

@lgeiger

Hi matplotlib developers,

I noticed some inconstancies regarding text rendering with usetex=True.
I placed the following text with plt.text() in my plot.

begin{eqnarray*}
\phi &=& 1.00 \pm 0.10 \\
a &=& 3.00 \pm 0.30 m \\
\frac{\chi^2}{ndof} &=& 1.13
\end{eqnarray*}

If the plot is saved as .png or .pdf, the whitespace around the equal signs is to big:
bildschirmfoto 2015-08-18 um 20 34 40

If saved as .svg everything looks good:
bildschirmfoto 2015-08-18 um 20 34 27

It would be great if whitespace would be consistent in all file formats.
A possibility to align text without LaTeX would also be greatly appreciated.

Thanks

Activity

  1. added this to the milestone on Aug 18, 2015
  2. tacaswell commented on Aug 18, 2015

    @tacaswell
    Member

    There are two PRs open (#4873, #4872) that address this. Do either of them fix this?

    I think we might be delegating the equation rendering in the svg backend to your viewer.

  3. lgeiger commented on Aug 18, 2015

    @lgeiger
    Author

    For some reason the current matplotlib master doesn't work on my machine. So I'm not able to test the PRs at the moment.

    You are right, the error lies in the svg backend or in the viewer. The pdf and png renderings are equal to what LaTeX does outside of matplotlib.
    If the align* environment is used instead of eqnarray* with \usepackage{amsmath} in the preamble, everything is consistent across all file formats.

  4. tacaswell commented on Aug 19, 2015

    @tacaswell
    Member

    Oh, sorry I misread your post. If you are using usetex=True what you are getting as a png of the latex output embedded in your plot so it is 'correct' (in that we use latex as the reference standard for our internal mathtex layout engine which is what those PRs are working on).

  5. modified the milestones: , on Oct 3, 2017
  6. github-actions commented on Mar 16, 2023

    @github-actions

    This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

  7. added
    status: closed as inactiveIssues closed by the "Stale" Github Action. Please comment on any you think should still be open.
    on May 30, 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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions