Skip to content

inaccurate marker positioning in plot() #7233

Open

Description

@anntzer

mpl 1.5.3/2.0b4/master, no matplotlibrc

_xs = np.linspace(0, 30, 201); plt.plot(_xs, scipy.stats.lognorm.pdf(_xs / 14, .472) / 14, ".")

plot

Note the slight inaccuracy in positioning of the markers at the positioning of the markers at the positions marked with the red circles, resulting in a "step-like" behavior (you may need to open the image in a larger viewer to notice it).

The data itself does not present this behavior, as can be checked just by zooming in these regions.

Activity

  1. efiring commented on Oct 7, 2016

    @efiring
    Member

    I wonder whether it is just a limitation on the ability of antialiasing to deliver a visual impression of sub-pixel accuracy. The steppiness is at the one-pixel level, but it doesn't look like simple pixel-snapping.

  2. tacaswell commented on Oct 8, 2016

    @tacaswell
    Member

    Turning snapping off does not help that much. I wonder if this is related to the way we 'stamp' the markers?

    attn @mdboom

  3. added this to the milestone on Oct 8, 2016
  4. tacaswell commented on Oct 29, 2016

    @tacaswell
    Member
    import numpy
    import scipy.stats
    import matplotlib.pyplot as plt
    plt.ion()
    fig, ax = plt.subplots()
    _xs = np.linspace(0, 30, 201); 
    ln, = ax.plot(_xs, scipy.stats.lognorm.pdf(_xs / 14, .472) / 14, ".")
  5. modified the milestones: , on Oct 29, 2016
  6. modified the milestones: , on Nov 10, 2016
  7. mdboom commented on Dec 5, 2016

    @mdboom
    Member

    Yes, it's definitely related to how we stamp the markers. We don't do individual subpixel positioning for the markers. We could do that but it would be significantly slower (so should be a user-configurable option).

  8. gson1703 commented on Aug 3, 2017

    @gson1703

    I'm also suffering from this issue. See the attached script and image for an example of what happens to a grid of evenly spaced markers. This level of quality is simply not acceptable for professional use - it looks like something out of the 1980s, but this 2017, and subpixel positioning is no longer optional.

    grid.py.txt
    detail

  9. WeatherGod commented on Aug 3, 2017

    @WeatherGod
    Member

    Could you repost that example. The link appears to be broken.

  10. WeatherGod commented on Aug 3, 2017

    @WeatherGod
    Member

    I would be curious if this is something that could be resolved with the Cairo rework?

  11. gson1703 commented on Aug 3, 2017

    @gson1703
    import math
    import numpy
    import matplotlib
    matplotlib.use('Agg')
    import matplotlib.pyplot as plt
    plt.style.use('dark_background')
    fig = plt.figure()
    ax = fig.add_subplot(111)
    xv = []
    yv = []
    for y in range(10):
        for x in range(10):
            xv.append(x * 0.147)
            yv.append(y * 0.147)
    ax.set_xlim(0, 10)
    ax.set_ylim(0, 10)
    plt.scatter(xv, yv)
    fig.savefig('grid.png')
  12. anntzer commented on Aug 3, 2017

    @anntzer
    ContributorAuthor

    @WeatherGod It is indeed solved by mpl_cairo (in fact this was one of the original motivations for writing it). See second example at https://gitter.im/matplotlib/matplotlib?at=5963202789aea4761d81a829. (You even commenter right under it :-))
    As a side note mpl_cairo also stamps the markers much faster (there's a timing script in the examples).

  13. WeatherGod commented on Aug 3, 2017

    @WeatherGod
    Member
  14. 17 remaining items

  15. modified the milestones: v3.2.0, v3.3.0 on Aug 13, 2019
  16. added
    Difficulty: Hardhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issues
    on Aug 13, 2019
  17. Jona-L commented on Apr 22, 2020

    @Jona-L

    not sure if related or said before, but either:

    • the pixel marker position is 1 pixel too high when other markers are fine
    • other markers positions are 1 pixel too low, while the pixel marker position if fine
      (depending on if the axis is positioned correctly as well)

    example:

    plt.xlim(0, 3)
    plt.ylim(0, 3)
    plt.plot(.05, 1, ',b')
    plt.plot(.1, 1, '.b')
    plt.plot(.2, 1, 'ob', ms=10, mew=1)
    plt.plot(.3, 1, ',b')
    plt.plot(.3, 1, 'or', fillstyle='none', ms=10, mew=1)
    plt.plot(.4, 1, '.b', ms=9)
    plt.plot(.4, 1, 'or', fillstyle='none', ms=10, mew=1)    
    plt.savefig('tst.png', dpi=100)
    

    image

  18. modified the milestones: v3.3.0, v3.4.0 on May 7, 2020
  19. modified the milestones: v3.4.0, on Jan 26, 2021
  20. modified the milestones: , needs sorting on Oct 6, 2022
  21. github-actions commented on Oct 9, 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!

  22. added
    keepItems to be ignored by the “Stale” Github Action
    and removed
    status: inactiveMarked by the “Stale” Github Action
    on Oct 9, 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

    Labels

    Difficulty: Hardhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issueskeepItems to be ignored by the “Stale” Github Action

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions