Skip to content

Commit bfa4403

Browse files
committed
fix problem with map contour and polymask use of newest matplotlib
1 parent d2e0c57 commit bfa4403

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

GSASII/GSASIIimage.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,9 +1287,12 @@ def polymask(data,Poly):
12871287
ax0.fill(px,py,inmask)
12881288
ax0.set_xbound(0,Nx)
12891289
ax0.set_ybound(0,Ny)
1290-
agg = canvas.switch_backends(hcCanvas)
1291-
agg.draw()
1292-
img, (width, height) = agg.print_to_buffer()
1290+
try:
1291+
agg = canvas.switch_backends(hcCanvas)
1292+
agg.draw()
1293+
img, (width, height) = agg.print_to_buffer()
1294+
except AttributeError:
1295+
img, (width,height) = canvas.print_to_buffer()
12931296
Zimg = np.frombuffer(img, np.uint8).reshape((height, width, 4))
12941297
return Zimg[:,:,0]
12951298

GSASII/GSASIIplot.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7430,9 +7430,12 @@ def Draw(caller='',Fade=[],NPkey=False):
74307430
contourSet = ax0.contour(ZU,colors='k',linewidths=1)
74317431
ax0.axis("off")
74327432
figure.subplots_adjust(bottom=0.,top=1.,left=0.,right=1.,wspace=0.,hspace=0.)
7433-
agg = canvas.switch_backends(hcCanvas)
7434-
agg.draw()
7435-
img, (width, height) = agg.print_to_buffer()
7433+
try:
7434+
agg = canvas.switch_backends(hcCanvas)
7435+
agg.draw()
7436+
img, (width, height) = agg.print_to_buffer()
7437+
except AttributeError:
7438+
img, (width,height) = canvas.print_to_buffer()
74367439
Zimg = np.frombuffer(img, np.uint8).reshape((height, width, 4))
74377440
RenderViewPlane(msize*eplane,Zimg,width,height)
74387441
try:

0 commit comments

Comments
 (0)