Skip to content

Tiles seem to overlap in zoomed out hexbin #7841

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dstansby opened this issue Jan 16, 2017 · 9 comments
Closed

Tiles seem to overlap in zoomed out hexbin #7841

dstansby opened this issue Jan 16, 2017 · 9 comments
Assignees

Comments

@dstansby
Copy link
Member

When looking at a zoomed out hexbin plot, the tiles seem to overlap, with the right-most tiles lying on top of the left-most tiles. This is present on master (see http://matplotlib.org/devdocs/_images/hexbin_demo.png), and here is an example (it helps to zoom into the .png image):

screenshot from 2017-01-16 13-27-39

@tacaswell tacaswell modified the milestones: 2.0 (style change major release), 2.0.1 (next bug fix release) Jan 16, 2017
@tacaswell
Copy link
Member

This also happen in 2.0.0rc2

http://matplotlib.org/2.0.0rc2/_images/hexbin_demo.png

However this is not a regression, it has been like this for a long time: http://matplotlib.org/1.2.1/_images/hexbin_demo.png

@efiring
Copy link
Member

efiring commented Jan 16, 2017

This is the ever-present problem of filling adjacent patches--the same as the problems with contourf. If the edges are not stroked at all, there are light artifacts. If the edges are stroked, as has always been the choice in hexbin, then the patches overlap, which is what is we see here. Turning anti-aliasing on or off modifies the artifacts, and their behavior also changes depending on alpha, but the upshot is that we have never found a solution for this problem. It seems to be a general problem with renderers. For hexbin, using a thin edgewidth helps.

@QuLogic QuLogic modified the milestones: 2.0.1 (next bug fix release), 2.0.2 (next bug fix release) May 3, 2017
@anntzer
Copy link
Contributor

anntzer commented Jun 29, 2017

https://lists.cairographics.org/archives/cairo/2007-July/011098.html may be relevant (to explain the issue, not to solve it).

@anntzer
Copy link
Contributor

anntzer commented Jul 10, 2017

It may be possible to fix this issue by drawing the hexbin as a quadmesh rather than a polycollection.

@efiring
Copy link
Member

efiring commented Jul 10, 2017

I don't think so. First, hexagons are not quadrilaterals. Second, the quadmesh is not immune to the adjacent patch rendering problems.

@anntzer
Copy link
Contributor

anntzer commented Jul 10, 2017

  1. A hexagon can be represented as two quadrilaterals (in fact, splitting each hexagon in a top and a bottom half actually gives you a proper quadmesh).
  2. I see no seams in https://files.gitter.im/matplotlib/matplotlib/9dTT/default-quadmesh.png (produced by Agg), so I assume that Agg (and cairo) do have special handling for them. (At least on cairo's side, the entire quadmesh is defined before rendering, so it should have all the info to compute the seams between the quads.)

@efiring
Copy link
Member

efiring commented Jul 10, 2017

  1. Yes, of course one can do this.
  2. The Agg rendering seems to work well with and without antialiasing, provided alpha is 1. It does not do so well with alpha = 0.3, for example. Still, an improvement for the alpha=1 case is worthwhile, so I like your idea.
    alpha3

@efiring
Copy link
Member

efiring commented Jul 10, 2017

It seems there is an inaccuracy in agg quadmesh, though:

x = np.arange(4)
y = np.arange(3)
z = np.arange(6).reshape(2, 3)
X, Y = np.meshgrid(x, y)
pcolormesh(X+Y, X-Y, z)
savefig('skewed.png')

All of the corners are slightly chopped off, with the top corner being the most obvious.
skewed

@QuLogic
Copy link
Member

QuLogic commented Mar 4, 2023

Closing as duplicate of #1188.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants