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

Tick labels containing the digit "1" slightly misaligned in some plot exports · Issue #6847 · matplotlib/matplotlib · GitHub

Repository navigation

Tick labels containing the digit "1" slightly misaligned in some plot exports #6847

Closed as not planned

Description

Hi,

Hopefully, my issue is not too unimportant and this is the right place to ask about it.
I experienced a minor problem, when using the plt.savefig function to save my plots to either .png (and also for .jpg) with a high resolution (300 dpi). If I specified to not use the standard font but set a font family to serif (plt.rcParams["font.family"] = "serif") all x-axis labels containing the digit "1", that I tried, namely 0.1 and 1.0 are misaligned in y-direction by 1 pixel. It's not noticeable most of the time, but when one has two subplots next to each other and the 1.0 label of one plot and the 0.0 label of the other are really next to each other, the labels look off.

As a minimal working example you can run:

import matplotlib
import matplotlib.pyplot as plt

plt.rcParams["font.family"] = "serif"

fig, ax = plt.subplots(1, 1)
plt.savefig("minimalExample.png", dpi=300)

and then zoom in onto 0.8 and 1.0. You can see the difference best, when you compare the decimal points.

Here is also a picture of the zoom and one of the two subplots, where I saw the problem first:

I tried this on a Linux machine with python version 2.7.9 and matplotlib versions 1.4.2 installed from debian repositories and 1.5.1 installed via pip.
Generally, this is not a big problem, though, as one can use alternate formats like pdf or eps if one really cares about a one pixel misalignment. Nonetheless, I thought, I might let you know. Feel free to close/delete this issue, if you consider it as too unimportant (or if this is the wrong place to raise it, as it might just be an external libraries fault).

Best (and thanks for this great package),

Jonathan

Activity

  1. added this to the milestone on Jul 28, 2016
  2. modified the milestones: , on May 3, 2017
  3. modified the milestones: , on Oct 9, 2017
  4. github-actions commented on Mar 27, 2023

    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!

  5. tacaswell commented on Mar 27, 2023

    Member

    This is still an issue and appears to be font dependent.

    with dejavu serif (using "serif" just means "find font in this list", on my system the one it picks in dejavu):

    with dejavu sans:

    Speculation on what could be going on here:

    • inherent issues with pixel snapping
    • we are doing something wrong computing the bounding boxes
    • font metrics in the font could be wonky / wrong
    • the '1' is just a pixel bigger

    It should also be noted that the x-axis ticks have vertical alignment of "top" so if the bounding boxes are varying at all I would expect the offsets to appear at the bottom.

  6. github-actions commented on Apr 1, 2024

    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 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: closed as inactiveIssues closed by the "Stale" Github Action. Please comment on any you think should still be open.status: inactiveMarked by the “Stale” Github Actiontopic: text

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL