Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Bug with PatchCollection in PDF output #1860

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
Mar 28, 2013
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Fixes #1860: Unfilled members of collections are not handled correctl…
…y in the PDF backend. Also fixes a related bug that alpha could not be set on individual members of a collection.
  • Loading branch information
mdboom committed Mar 27, 2013
commit 4f2ecf2ba0f8861e89a6841af5f99add873db3b3
20 changes: 14 additions & 6 deletions 20 lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,8 @@ def _iter_collection(self, gc, master_transform, all_transforms,
gc0 = self.new_gc()
gc0.copy_properties(gc)

original_alpha = gc.get_alpha()

if Nfacecolors == 0:
rgbFace = None

Expand All @@ -374,22 +376,28 @@ def _iter_collection(self, gc, master_transform, all_transforms,
yo = -(yp - yo)
if not (np.isfinite(xo) and np.isfinite(yo)):
continue
gc0.set_alpha(original_alpha)
if Nfacecolors:
rgbFace = facecolors[i % Nfacecolors]
if Nedgecolors:
fg = edgecolors[i % Nedgecolors]
if Nfacecolors == 0 and len(fg)==4:
gc0.set_alpha(fg[3])
gc0.set_foreground(fg)
if Nlinewidths:
gc0.set_linewidth(linewidths[i % Nlinewidths])
if Nlinestyles:
gc0.set_dashes(*linestyles[i % Nlinestyles])
if rgbFace is not None and len(rgbFace)==4:
fg = edgecolors[i % Nedgecolors]
if len(fg) == 4:
if fg[3] == 0.0:
gc0.set_linewidth(0)
else:
gc0.set_alpha(gc0.get_alpha() * fg[3])
gc0.set_foreground(fg[:3])
else:
gc0.set_foreground(fg)
if rgbFace is not None and len(rgbFace) == 4:
if rgbFace[3] == 0:
rgbFace = None
else:
gc0.set_alpha(rgbFace[3])
gc0.set_alpha(gc0.get_alpha() * rgbFace[3])
rgbFace = rgbFace[:3]
gc0.set_antialiased(antialiaseds[i % Naa])
if Nurls:
Expand Down
30 changes: 28 additions & 2 deletions 30 lib/matplotlib/backends/backend_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1523,10 +1523,36 @@ def draw_path_collection(self, gc, master_transform, paths, all_transforms,
offsets, offsetTrans, facecolors, edgecolors,
linewidths, linestyles, antialiaseds, urls,
offset_position):
# We can only reuse the objects if the presence of fill and
# stroke (and the amount of alpha for each) is the same for
# all of them
can_do_optimization = True

if not len(facecolors):
filled = False
else:
if np.all(facecolors[:, 3] == facecolors[0, 3]):
filled = facecolors[0, 3] != 0.0
else:
can_do_optimization = False

if not len(edgecolors):
stroked = False
else:
if np.all(edgecolors[:, 3] == edgecolors[0, 3]):
stroked = edgecolors[0, 3] != 0.0
else:
can_do_optimization = False

if not can_do_optimization:
return RendererBase.draw_path_collection(
self, gc, master_transform, paths, all_transforms,
offsets, offsetTrans, facecolors, edgecolors,
linewidths, linestyles, antialiaseds, urls,
offset_position)

padding = np.max(linewidths)
path_codes = []
filled = len(facecolors)
stroked = len(edgecolors)
for i, (path, transform) in enumerate(self._iter_collection_raw_paths(
master_transform, paths, all_transforms)):
name = self.file.pathCollectionObject(
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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.