GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — PathCollection (and therefore Scatter) points are badly placed since v1.4 · Issue #7262 · matplotlib/matplotlib

PathCollection (and therefore Scatter) points are badly placed since v1.4 #7262

New issue
Copy link
New issue
Copy link
Open
#32108
Open
PathCollection (and therefore Scatter) points are badly placed since v1.4#7262
#32108
Copy link
Labels
keepItems to be ignored by the “Stale” Github ActionItems to be ignored by the “Stale” Github Action
Milestone
future releases

Description

@pelson
pelson
opened on Oct 12, 2016
Issue body actions

Since https://github.com/matplotlib/matplotlib/pull/2156/files#diff-506c6bd01694bddbd8999f2c6e920705R283 scatter has used renderer.draw_markers for same scale/color/style marker plots. Unfortunately, it appears that this code path snaps marker locations inconsistently with how they were placed before.

First off, some code:

import matplotlib.pyplot as plt
import numpy as np
import matplotlib

x = np.linspace(0, 10, 200).astype(np.float32)
y = np.sin(x)

offsets = np.dstack((x, y))

ax = plt.axes()

# Create a PathCollection to mirror the scatter behaviour.
def my_scatter(x, y):
    from matplotlib.collections import PathCollection
    from matplotlib.path import Path
    import matplotlib.transforms as mtransforms

    phi = np.linspace(0, 2 * np.pi, 100)
    # Scale, in pixel coordinates
    rad = 2
    x_circle = np.cos(phi) * rad
    y_circle = np.sin(phi) * rad

    verts = np.vstack([x_circle, y_circle]).T
    path = Path(verts, closed=False)
    collection = PathCollection([path], facecolor='blue', edgecolor='black',
                                offsets=offsets,
                                transOffset=ax.transData,
                                )
    collection.set_transform(mtransforms.IdentityTransform())
    ax.add_collection(collection, autolim=True)

    ax.autoscale()


my_scatter(x, y)
ax.plot(x, y)
ax.grid(True)

plt.savefig('scatter.{}.png'.format(matplotlib.__version__))

plt.show()

In mpl 1.3:

scatter 1 3 1

In mpl 1.5
scatter 1 5 2

If you open both of these images in new tabs and flick between them, you will see the jitter that the above comment has introduced.

I'm reporting this as an investigation on behalf of @bjlittle. I'm not certain I'm going to get a huge amount of time to address this problem, but maybe some hints from @mdboom might enable @bjlittle to take a look at fixing the problem.

Reacted by Nico Schlömer, marko-pi and Juhan Oskar Hennoste

Activity

  1. anntzer commented on Oct 12, 2016

    @anntzer
    anntzer
    on Oct 12, 2016
    Contributor
    More actions

    I have some issues installing 1.3 right now to check but I wonder whether this is the same issue as #7233. Can you give it a try and consolidate the two issues if this is the case?

  2. Kojoley commented on Oct 12, 2016

    @Kojoley
    Kojoley
    on Oct 12, 2016
    Member
    More actions

    I wonder whether this is the same issue as #7233

    I think it is.

    1.4.0
    issue_7262-1.4.0.png

    1.3.1
    issue_7262-1.3.1.png

  3. Kojoley commented on Oct 12, 2016

    @Kojoley
    Kojoley
    on Oct 12, 2016
    Member
    More actions

    I have some issues installing 1.3

    I have to downgrade numpy to 1.6.0 to install matplotlib 1.3

  4. tacaswell
    added this to the This milestone has been deleted milestone on Oct 29, 2016
  5. tacaswell commented on Oct 29, 2016

    @tacaswell
    tacaswell
    on Oct 29, 2016
    Member
    More actions

    Disabling the fast-path does fix this

    diff --git a/lib/matplotlib/collections.py b/lib/matplotlib/collections.py
    index 5997192..63aa9ec 100644
    --- a/lib/matplotlib/collections.py
    +++ b/lib/matplotlib/collections.py
    @@ -328,7 +328,7 @@ class Collection(artist.Artist, cm.ScalarMappable):
                     extents.height < height):
                     do_single_path_optimization = True
    
    -        if do_single_path_optimization:
    +        if False and do_single_path_optimization:
                 gc.set_foreground(tuple(edgecolors[0]))
                 gc.set_linewidth(self._linewidths[0])
                 gc.set_dashes(*self._linestyles[0])
    

    scatter 2 0 0b4 post252 dev0 g92da7f6

    One other thing to notice is that in 1.4+ the (0, 0) marker is right on the intersection of the two grid lines, where as for 1.3.1 the marker is off by a bit.

    I am pretty sure that the underlying problem is in draw_markers and related to snapping.

  6. tacaswell commented on Oct 29, 2016

    @tacaswell
    tacaswell
    on Oct 29, 2016
    Member
    More actions

    attn @mdboom

  7. NelleV
    modified the milestones: This milestone has been deleted, This milestone has been deleted on Nov 10, 2016
  8. mdboom commented on Dec 5, 2016

    @mdboom
    mdboom
    on Dec 5, 2016
    Member
    More actions

    I'd suggest making the fast path optimization an rcParam -- and @tacaswell's code snippet above highlights exactly where to use it. There are good reasons to have it -- particularly for large point clouds in astronomy which is where it first came from. But clearly there are also good reasons not to have it.

  9. anntzer commented on Feb 24, 2017

    @anntzer
    anntzer
    on Feb 24, 2017
    Contributor
    More actions

    Turning off the fast path optimization does not solve #7624, so there may be multiple issues at hand here...

  10. brunodigiorgi commented on Mar 12, 2017

    @brunodigiorgi
    brunodigiorgi
    on Mar 12, 2017
    More actions

    I noticed that plotting the markers one at a time solves this problem in my case:

    def draw_markers(points, marker, markersize, mew, mec, mfc, snap, ax):
        for p in points:
            ax.plot(p[0], p[1], marker=marker, markersize=markersize, mew=mew, mec=mec, mfc=mfc, snap=snap)
    
  11. tacaswell
    modified the milestones: This milestone has been deleted, This milestone has been deleted on Sep 24, 2017
  12. github-actions commented on Mar 31, 2023

    @github-actions
    github-actionsBot
    on Mar 31, 2023
    More 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!

  13. github-actions
    added
    status: inactiveMarked by the “Stale” Github ActionMarked by the “Stale” Github Action
    on Mar 31, 2023
  14. anntzer
    added
    keepItems to be ignored by the “Stale” Github ActionItems to be ignored by the “Stale” Github Action
    on Mar 31, 2023
  15. rcomer
    removed
    status: inactiveMarked by the “Stale” Github ActionMarked by the “Stale” Github Action
    on Mar 31, 2023
  16. jklymak
    marked [Bug]: Minor "squiggles" in spy output #32506 as a duplicate of this issue on Oct 20, 2026
  17. QuLogic
    linked a pull request that will close this issueSnap markers to subpixels instead of whole ones #32108on Oct 21, 2026
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

    keepItems to be ignored by the “Stale” Github ActionItems to be ignored by the “Stale” Github Action

    Type

    No type

    Projects

    No projects

      Milestone

      • future releasesNo due date

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.