def prettyaxesbox(ax=None, linewidth=None, edgecolor="k", facecolor="none", front=True): """ Replaces the box around the axes with a fancybox. This makes it an actual box and not just four lines. If linewidth is None, uses the initialized linewidth. """ # First, figure out what axes object to use. if ax is None: ax = plt.gca() # Get linewidth if necessary. if linewidth is None: linewidth = 1 # Now we're going to make the box around the axes look better. ap = ax.axesPatch zorders = [c.get_zorder() for c in ax.get_children()] if front: z = max(zorders) + 1 else: z = min(zorders) - 1 prettybox = FancyBboxPatch(ap.get_xy(), ap.get_width(), ap.get_height(), boxstyle="square,pad=0.", ec=edgecolor, fc=facecolor, transform=ap.get_transform(), lw=linewidth, zorder=z) # Make current box invisible and make our better one. ap.set_edgecolor("none") ax.set_frame_on(False) ax.add_patch(prettybox) prettybox.set_clip_on(False) plt.draw() return prettybox
maxw, minw = maxwg, minwg elif cscale == 'local': maxw, minw = maxwl, minwl ax = fig.add_subplot(10, 30, h + 1) if globflags[h]: autoaxis = ax.axis() print(autoaxis) # rec=Rectangle((autoaxis[0],autoaxis[2]),(autoaxis[1]-autoaxis[0]),(autoaxis[3]-autoaxis[2]),fill=False,lw=1) # rec=Rectangle((autoaxis[0]-2,autoaxis[2]-2),(autoaxis[1]-autoaxis[0])+17,(autoaxis[3]-autoaxis[2])+17,fill=False,lw=2) # rec=Rectangle((-2,-2),18,18,fill=False,lw=1) bbox = FancyBboxPatch((-1, -1), 17, 17, fill=False, lw=2) # bbox=FancyBboxPatch((autoaxis[0],autoaxis[2]),(autoaxis[1]-autoaxis[0]),(autoaxis[3]-autoaxis[2])) # rec=ax.add_patch(rec) # ax.add_patch(bbox) bbox = ax.add_patch(bbox) bbox.set_clip_on(False) # rec.set_clip_on(False) ax.imshow(this_W, interpolation='nearest', vmin=minwl, vmax=maxwl, cmap='jet') ax.axis('off') # print("subplot {}".format(h)) # fig = plt.figure(figsize=(30,10)) fig.savefig("{}montage_images/W_e_{:03}.jpg".format(outputdir, e)) plt.close(fig) if not os.path.exists('{}montage_images/hist_W_e_{:03}.jpg'.format( outputdir, e)): fig = plt.figure(figsize=(30, 10))