8000 Fix a crash when saving to PDF or SVG with contour hatching. by mdboom · Pull Request #891 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Fix a crash when saving to PDF or SVG with contour hatching. #891

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

Merged
merged 2 commits into from
May 27, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/matplotlib/backends/backend_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,9 @@ def alphaState(self, alpha):
return name

def hatchPattern(self, hatch_style):
# The colors may come in as numpy arrays, which aren't hashable
hatch_style = (tuple(hatch_style[0]), tuple(hatch_style[1]), hatch_style[2])
Copy link
Member

Choose a reason for hiding this comment

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

I had to look up what hatch_style actually was. Maybe its worth stating in the docstring that it's hatch_style = (self._rgb, self._fillcolor, hatch) and what hatch is. Actually, what is hatch :-)? Is it always immutable or hashable?

Copy link
Member Author

Choose a reason for hiding this comment

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

No -- many of the backends don't require it to be hashable. This change is really an implementation detail of the PDF and SVG backends.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I was referring to hatch_style[2].

Copy link
Member Author

Choose a reason for hiding this comment

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

hatch_style[2] should always be a string (and thus hashable)

Copy link
Member

Choose a reason for hiding this comment

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

Thanks Mike. As I said, I think this line would benefit from a comment indicating what hatch_style is likely to be.


pattern = self.hatchPatterns.get(hatch_style, None)
if pattern is not None:
return pattern
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/backends/backend_svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def _get_hatch(self, gc, rgbFace):
"""
Create a new hatch pattern
"""
dictkey = (gc.get_hatch(), rgbFace, gc.get_rgb())
dictkey = (gc.get_hatch(), tuple(rgbFace), tuple(gc.get_rgb()))
oid = self._hatchd.get(dictkey)
if oid is None:
oid = self._make_id(u'h', dictkey)
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
0