Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e1c50e2

Browse files
committed
Fix PDF collection rendering
1 parent 3b136ee commit e1c50e2

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

lib/matplotlib/backends/backend_pdf.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ def close(self):
507507
xobjects[tup[0]] = tup[1]
508508
for name, value in self.multi_byte_charprocs.iteritems():
509509
xobjects[name] = value
510-
for name, path, trans, ob, join, cap, padding in self.paths:
510+
for name, path, trans, ob, join, cap, padding, filled, stroked in self.paths:
511511
xobjects[name] = ob
512512
self.writeObject(self.XObjectObject, xobjects)
513513
self.writeImages()
@@ -1267,15 +1267,17 @@ def writeMarkers(self):
12671267
self.output(Op.paint_path(False, fillp, strokep))
12681268
self.endStream()
12691269

1270-
def pathCollectionObject(self, gc, path, trans, padding):
1270+
def pathCollectionObject(self, gc, path, trans, padding, filled, stroked):
12711271
name = Name('P%d' % len(self.paths))
12721272
ob = self.reserveObject('path %d' % len(self.paths))
12731273
self.paths.append(
1274-
(name, path, trans, ob, gc.get_joinstyle(), gc.get_capstyle(), padding))
1274+
(name, path, trans, ob, gc.get_joinstyle(), gc.get_capstyle(), padding,
1275+
filled, stroked))
12751276
return name
12761277

12771278
def writePathCollectionTemplates(self):
1278-
for (name, path, trans, ob, joinstyle, capstyle, padding) in self.paths:
1279+
for (name, path, trans, ob, joinstyle, capstyle, padding, filled,
1280+
stroked) in self.paths:
12791281
pathops = self.pathOperations(path, trans, simplify=False)
12801282
bbox = path.get_extents(trans)
12811283
if not np.all(np.isfinite(bbox.extents)):
@@ -1290,7 +1292,7 @@ def writePathCollectionTemplates(self):
12901292
self.output(GraphicsContextPdf.joinstyles[joinstyle], Op.setlinejoin)
12911293
self.output(GraphicsContextPdf.capstyles[capstyle], Op.setlinecap)
12921294
self.output(*pathops)
1293-
self.output(Op.paint_path(False, True, True))
1295+
self.output(Op.paint_path(False, filled, stroked))
12941296
self.endStream()
12951297

12961298
@staticmethod
@@ -1504,12 +1506,14 @@ def draw_path_collection(self, gc, master_transform, paths, all_transforms,
15041506
offsets, offsetTrans, facecolors, edgecolors,
15051507
linewidths, linestyles, antialiaseds, urls,
15061508
offset_position):
1507-
15081509
padding = np.max(linewidths)
15091510
path_codes = []
1511+
filled = len(facecolors)
1512+
stroked = len(edgecolors)
15101513
for i, (path, transform) in enumerate(self._iter_collection_raw_paths(
15111514
master_transform, paths, all_transforms)):
1512-
name = self.file.pathCollectionObject(gc, path, transform, padding)
1515+
name = self.file.pathCollectionObject(
1516+
gc, path, transform, padding, filled, stroked)
15131517
path_codes.append(name)
15141518

15151519
output = self.file.output

0 commit comments

Comments
 (0)