def show_chip_distinctiveness_plot(chip, kpts, dstncvs, fnum=1, pnum=None): import plottool as pt pt.figure(fnum, pnum=pnum) ax = pt.gca() divider = pt.ensure_divider(ax) #ax1 = divider.append_axes("left", size="50%", pad=0) ax1 = ax ax2 = divider.append_axes("bottom", size="100%", pad=0.05) #f, (ax1, ax2) = pt.plt.subplots(1, 2, sharex=True) cmapstr = 'rainbow' # 'hot' color_list = pt.df2.plt.get_cmap(cmapstr)(ut.norm_zero_one(dstncvs)) sortx = dstncvs.argsort() #pt.df2.plt.plot(qfx2_dstncvs[sortx], c=color_list[sortx]) pt.plt.sca(ax1) pt.colorline(np.arange(len(sortx)), dstncvs[sortx], cmap=pt.plt.get_cmap(cmapstr)) pt.gca().set_xlim(0, len(sortx)) pt.dark_background() pt.plt.sca(ax2) pt.imshow(chip, darken=.2) # MATPLOTLIB BUG CANNOT SHOW DIFFERENT ALPHA FOR POINTS AND KEYPOINTS AT ONCE #pt.draw_kpts2(kpts, pts_color=color_list, ell_color=color_list, ell_alpha=.1, ell=True, pts=True) #pt.draw_kpts2(kpts, color_list=color_list, pts_alpha=1.0, pts_size=1.5, # ell=True, ell_alpha=.1, pts=False) ell = ut.get_argflag('--ell') pt.draw_kpts2(kpts, color_list=color_list, pts_alpha=1.0, pts_size=1.5, ell=ell, ell_alpha=.3, pts=not ell) pt.plt.sca(ax)
def plot_chip(self, aid, nRows, nCols, px, **kwargs): """ Plots an individual chip in a subaxis """ ibs = self.ibs enable_chip_title_prefix = ut.is_developer() #enable_chip_title_prefix = False if aid in self.comp_aids: score = self.cm.get_annot_scores([aid])[0] rawscore = self.cm.get_annot_scores([aid])[0] title_suf = kwargs.get('title_suffix', '') if score != rawscore: if score is None: title_suf += '\n score=____' else: title_suf += '\n score=%0.2f' % score title_suf += '\n rawscore=%0.2f' % rawscore else: title_suf = kwargs.get('title_suffix', '') if enable_chip_title_prefix: title_suf = '\n' + title_suf #nid = ibs.get_annot_name_rowids(aid) viz_chip_kw = { 'fnum': self.fnum, 'pnum': (nRows, nCols, px), 'nokpts': True, 'show_gname': False, 'show_exemplar': False, 'show_num_gt': False, 'show_gname': False, 'title_suffix': title_suf, # 'text_color': kwargs.get('color'), ### #'show_name': False, #'show_aidstr': False, 'enable_chip_title_prefix': enable_chip_title_prefix, 'show_name': True, 'show_aidstr': True, 'show_yawtext': True, 'show_quality_text': True, } viz_chip.show_chip(ibs, aid, **viz_chip_kw) ax = pt.gca() if kwargs.get('make_buttons', True): divider = pt.ensure_divider(ax) butkw = {'divider': divider, 'size': '13%'} self.aid2_ax = {} self.aid2_border = {} if aid in self.comp_aids: callback = partial(self.select, aid) self.append_button('Select This Animal', callback=callback, **butkw) #Hack to toggle colors if aid in self.aid_checkbox_states: #If we are selecting it, then make it green, otherwise change it back to grey if self.aid_checkbox_states[aid]: border = pt.draw_border(ax, color=(0, 1, 0), lw=4) else: border = pt.draw_border(ax, color=(.7, .7, .7), lw=4) self.aid2_border[aid] = border else: self.aid_checkbox_states[aid] = False self.append_button('Examine', callback=partial(self.examine, aid), **butkw)
def plot_chip(self, aid, nRows, nCols, px, **kwargs): """ Plots an individual chip in a subaxis """ ibs = self.ibs enable_chip_title_prefix = ut.is_developer() #enable_chip_title_prefix = False if aid in self.comp_aids: score = self.cm.get_annot_scores([aid])[0] rawscore = self.cm.get_annot_scores([aid])[0] title_suf = kwargs.get('title_suffix', '') if score != rawscore: if score is None: title_suf += '\n score=____' else: title_suf += '\n score=%0.2f' % score title_suf += '\n rawscore=%0.2f' % rawscore else: title_suf = kwargs.get('title_suffix', '') if enable_chip_title_prefix: title_suf = '\n' + title_suf #nid = ibs.get_annot_name_rowids(aid) viz_chip_kw = { 'fnum': self.fnum, 'pnum': (nRows, nCols, px), 'nokpts': True, 'show_gname': False, 'show_exemplar': False, 'show_num_gt': False, 'show_gname': False, 'title_suffix': title_suf, # 'text_color': kwargs.get('color'), ### #'show_name': False, #'show_aidstr': False, 'enable_chip_title_prefix': enable_chip_title_prefix, 'show_name': True, 'show_aidstr': True, 'show_yawtext': True, 'show_quality_text': True, } viz_chip.show_chip(ibs, aid, **viz_chip_kw) ax = pt.gca() if kwargs.get('make_buttons', True): divider = pt.ensure_divider(ax) butkw = { 'divider': divider, 'size': '13%' } self.aid2_ax = {} self.aid2_border = {} if aid in self.comp_aids: callback = partial(self.select, aid) self.append_button('Select This Animal', callback=callback, **butkw) #Hack to toggle colors if aid in self.aid_checkbox_states: #If we are selecting it, then make it green, otherwise change it back to grey if self.aid_checkbox_states[aid]: border = pt.draw_border(ax, color=(0, 1, 0), lw=4) else: border = pt.draw_border(ax, color=(.7, .7, .7), lw=4) self.aid2_border[aid] = border else: self.aid_checkbox_states[aid] = False self.append_button('Examine', callback=partial(self.examine, aid), **butkw)