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

Hatching gap on agg backend by mdboom · Pull Request #853 · matplotlib/matplotlib · GitHub

Repository navigation

Hatching gap on agg backend - #853

Merged
mdboom merged 1 commit into
matplotlib:masterfrom
mdboom:hash_gaps
Apr 27, 2012
Merged

mdboom merged 1 commit into
matplotlib:masterfrom
mdboom:hash_gaps

Conversation

mdboom commented Apr 25, 2012

Copy link
Copy Markdown
Member

Every 72 pixels, with some hatch patterns, the hatch line is interrupted in the agg backend.

ax = plt.axes()
patch = mpatches.Rectangle([0, 0], 1, 1, transform=ax.transAxes, hatch='/', facecolor='none')
ax.add_patch(patch)

# put boxes where there are gaps (in device pixel coordinates)
fig = plt.gcf()
w, h = fig.transFigure.transform([1, 1])

box_height = 11 
box1_x, box1_y = 144 - box_height/2, h - 145 + box_height/2

for i in xrange(3):
    for j in xrange(3):
        patch = mpatches.Rectangle([box1_x + i*72, box1_y - j*72], box_height, box_height, transform=None, facecolor='none')
        fig.patches.append(patch)

plt.show()

An interesting observation is that when using the hatch "x" the artefact doesn't exist, which suggests there may be an anti-aliasing influence at the edge of the tile before it is passed through as an agg::span_pattern_rgba.

I have tried changing the agg renderer in src/_backend_agg.cpp to renderer_bin for hatch pattern rendering, in the hope that it would be a simple anti-aliasing problem, but the problem persists. Unfortunately that is as far as I have been able to take it.

mdboom commented Apr 25, 2012

Copy link
Copy Markdown
Member

The attached PR should resolve this (I think). The corners of the hash pattern were not getting inked. Using parallel lines of the same length, rather than lines that shrink to zero length in the corners, seems to fix this problem. Agg draws a zero length line as nothing, whereas other renderers (Adobe Acrobat, for example) draw a zero length line as a point.

There is also a bug whereby the density of diagonal lines was much higher than horizontal or vertical ones so the spacing should be less crowded now. They can't be made to be the same, because the pattern is a fixed size regardless of line direction, so if the spacing of horizontal lines is 'x', the spacing of diagonal lines is \sqrt{2x^2}.

Comment thread lib/matplotlib/hatch.py

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This is not good when num_lines == 0 as we end up with a single point in the hatch pattern. 7242fd67921fff5c7651692e097cfdb7dde174ab, in my own branch from yours, fixes this and adds a fix to the anti-aliasing effect on horizontal and vertical hatches.

pelson commented Apr 26, 2012

Copy link
Copy Markdown
Member Author

Awesome response time Mike. It took me ages to look into this without success! (I guess my initial guess that it was an aa effect is to blame for that)

mdboom added a commit that referenced this pull request Apr 27, 2012
mdboom merged commit 3d19a08 into matplotlib:master Apr 27, 2012
mdboom deleted the hash_gaps branch March 3, 2015 18:43
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL