def __init__(self, fig, labelstr): artist.Artist.__init__(self) self.set_figure(fig) x, self.depth = self.parser.to_rgba(labelstr, color='black', fontsize=14, dpi=100) xHover, depth = self.parser.to_rgba(labelstr, color='white', fontsize=14, dpi=100) self.labelwidth = x.shape[1] self.labelheight = x.shape[0] print 'h', self.labelheight self.label = image.FigureImage(fig) self.label.set_array(x.astype(float) / 255.) self.labelHover = image.FigureImage(fig) self.labelHover.set_array(xHover.astype(float) / 255.) # we'll update these later self.rect = patches.Rectangle((0, 0), 1, 1, facecolor='yellow', alpha=0.2) self.rectHover = patches.Rectangle((0, 0), 1, 1, facecolor='blue', alpha=0.2)
def __init__(self, fig, labelstr, props=None, hoverprops=None, on_select=None): artist.Artist.__init__(self) self.set_figure(fig) self.labelstr = labelstr if props is None: props = ItemProperties() if hoverprops is None: hoverprops = ItemProperties() self.props = props self.hoverprops = hoverprops self.on_select = on_select x, self.depth = self.parser.to_mask(labelstr, fontsize=props.fontsize, dpi=fig.dpi) if props.fontsize != hoverprops.fontsize: raise NotImplementedError( 'support for different font sizes not implemented') self.labelwidth = x.shape[1] self.labelheight = x.shape[0] self.labelArray = np.zeros((x.shape[0], x.shape[1], 4)) self.labelArray[:, :, -1] = x / 255. self.label = image.FigureImage(fig, origin='upper') self.label.set_array(self.labelArray) # we'll update these later self.rect = patches.Rectangle((0, 0), 1, 1) self.set_hover_props(False) fig.canvas.mpl_connect('button_release_event', self.check_select)
def _plot(fig, hists, labels, n, show_ticks=None): """ Plot pair-wise correlation histograms """ if n <= 1: fig.text(0.5, 0.5, "No correlation plots when only one variable", ha="center", va="center") return vmin, vmax = inf, -inf for data, _, _ in hists.values(): positive = data[data > 0] if len(positive) > 0: vmin = min(vmin, np.amin(positive)) vmax = max(vmax, np.amax(positive)) norm = colors.LogNorm(vmin=vmin, vmax=vmax, clip=False) #norm = colors.Normalize(vmin=vmin, vmax=vmax) mapper = image.FigureImage(fig) mapper.set_array(np.zeros(0)) mapper.set_cmap(cmap=COLORMAP) mapper.set_norm(norm) if show_ticks is None: show_ticks = n < 3 ax = {} Nr = Nc = n - 1 for i in range(0, n - 1): for j in range(i + 1, n): sharex = ax.get((0, j), None) sharey = ax.get((i, i + 1), None) a = fig.add_subplot(Nr, Nc, (Nr - i - 1) * Nc + j, sharex=sharex, sharey=sharey) ax[(i, j)] = a a.xaxis.set_major_locator(MaxNLocator(4, steps=[1, 2, 4, 5, 10])) a.yaxis.set_major_locator(MaxNLocator(4, steps=[1, 2, 4, 5, 10])) data, x, y = hists[(i, j)] data = np.clip(data, vmin, vmax) a.pcolorfast(y, x, data, cmap=COLORMAP, norm=norm) # Show labels or hide ticks if i != 0: artist.setp(a.get_xticklabels(), visible=False) if i == n - 2 and j == n - 1: a.set_xlabel(labels[j]) #a.xaxis.set_label_position("top") #a.xaxis.set_offset_position("top") if not show_ticks: a.xaxis.set_ticks([]) if j == i + 1: a.set_ylabel(labels[i]) else: artist.setp(a.get_yticklabels(), visible=False) if not show_ticks: a.yaxis.set_ticks([]) a.zoomable = True # Adjust subplots and add the colorbar fig.subplots_adjust(left=0.07, bottom=0.07, top=0.9, right=0.85, wspace=0.0, hspace=0.0) cax = fig.add_axes([0.88, 0.2, 0.04, 0.6]) fig.colorbar(mapper, cax=cax, orientation='vertical') return ax
return None plot_post_psd(overwrite = True) #%% Tests to join psd plot_post = raws_filt[0].plot_psd(area_mode=None, show=True, average=False, ax=plt.axes(ylim=(0,60)),fmin =1.0, fmax=80.0, dB=False, n_fft=160) plot_pre = raws_filt[1].plot_psd(area_mode=None, show=True, average=False, ax=plt.axes(ylim=(0,60)),fmin =1.0, fmax=80.0, dB=False, n_fft=160) path = "C:\\Users\\admin\\Desktop\\eeGNN\\preprocessing\\psd_real\\pre_psd\\S23_real_pre.png" path2 = "C:\\Users\\admin\\Desktop\\eeGNN\\preprocessing\\psd_real\\pre_psd\\S66_real_pre.png" b = image.FigureImage(plot_post) c = image.FigureImage(plot_pre) a = [b,c] list_im = [path, path2] new_im = Image.new('RGB', (444,95)) #creates a new empty image, RGB mode, and size 444 by 95 for elem in list_im: im=Image.open(elem) print(elem) #im.show() new_im.paste(im, (i,0)) new_im.save('test2.jpg') #%% Other tests