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 — Hatching gap on agg backend by mdboom · Pull Request #853 · matplotlib/matplotlib

Conversation

@mdboom

@mdboom 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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mdboom
Fix small gaps in the hatching in Agg backend
21b9d43
@mdboom

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}.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

pelson
pelson reviewed Apr 26, 2012
View reviewed changes
Comment thread lib/matplotlib/hatch.py

@pelson pelson Apr 26, 2012

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@pelson

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)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mdboom added a commit that referenced this pull request Apr 27, 2012
@mdboom
Merge pull request #853 from mdboom/hash_gaps
3d19a08
Hatching gap on agg backend
@mdboom
mdboom merged commit 3d19a08 into matplotlib:master Apr 27, 2012
@pelson pelson mentioned this pull request Jun 10, 2012
Matplotlib does not display hatching when rendering to pdf #29
Closed
@mdboom
mdboom deleted the hash_gaps branch March 3, 2015 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@mdboom @pelson
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — 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.