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

Skip to content

Commit b25d275

Browse files
committed
Merge pull request matplotlib#1779 from mdboom/ps/python3
Bug in postscript backend in Python 3
2 parents 9b4e77d + df8c010 commit b25d275

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/matplotlib/backends/backend_ps.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ def draw_image(self, gc, x, y, im, dx=None, dy=None, transform=None):
469469
im.flipud_out()
470470

471471
h, w, bits, imagecmd = self._get_image_h_w_bits_command(im)
472-
hexlines = '\n'.join(self._hex_lines(bits))
472+
hexlines = b'\n'.join(self._hex_lines(bits)).decode('ascii')
473473

474474
if dx is None:
475475
xscale = w / self.image_magnification
@@ -1179,6 +1179,7 @@ def write(self, *kl, **kwargs):
11791179
print("end", file=fh)
11801180
print("showpage", file=fh)
11811181
if not isEPSF: print("%%EOF", file=fh)
1182+
fh.flush()
11821183

11831184
if rcParams['ps.usedistiller'] == 'ghostscript':
11841185
gs_distill(tmpfile, isEPSF, ptype=papertype, bbox=bbox)
@@ -1187,7 +1188,7 @@ def write(self, *kl, **kwargs):
11871188

11881189
if passed_in_file_object:
11891190
with open(tmpfile, 'rb') as fh:
1190-
print(fh.read(), file=outfile)
1191+
outfile.write(fh.read())
11911192
else:
11921193
with open(outfile, 'w') as fh:
11931194
pass
@@ -1293,6 +1294,7 @@ def write(self, *kl, **kwargs):
12931294
#print >>fh, "grestore"
12941295
print("end", file=fh)
12951296
print("showpage", file=fh)
1297+
fh.flush()
12961298

12971299
if isLandscape: # now we are ready to rotate
12981300
isLandscape = True

0 commit comments

Comments
 (0)