def structure_plot(fig, molids, activations=None):
    """plot molecule structures"""
    if activations != None:
        assert len(activations[0]) == len(molids[0])
        assert len(activations[1]) == len(molids[1])
    id2name = defaultdict(str, rdl.get_id2name())
    all_molids = molids[0] + molids[1]
    all_activations = np.hstack(activations)
    cr = utils.ceiled_root(len(all_molids))
    for i, molid in enumerate(all_molids):
        ax = fig.add_subplot(cr, cr, i+1)
        try:
            img = plt.imread(os.path.join(structures_path, molid + '.png'))
        except Exception, e:
            img = np.zeros(img.shape)
        ax.imshow(img)
        ax.set_xticks([])
        ax.set_yticks([])
        if i >= len(molids[0]):
            for child in ax.get_children():
                if isinstance(child, plt.matplotlib.spines.Spine):
                    child.set_color('#ff0000')
        if activations != None:
            ax.set_title('{}: {:.2f}'.format(id2name[molid], all_activations[i]),
                         rotation='20')
def plot_search_matrix(fig, desc_res, selection, method, glomeruli):
    """docstring for plot_search_matrix"""
    if not glomeruli:
        tmp_glomeruli = desc_res[selection].keys()
    else:
        tmp_glomeruli = glomeruli
    n = utils.ceiled_root(len(tmp_glomeruli))
    for i_glom, glom in enumerate(tmp_glomeruli):
        mat = desc_res[selection][glom][method]
        ax = fig.add_subplot(n, n, i_glom+1)
        if np.max(mat) < 0:
            ax.imshow(np.zeros(mat.shape), interpolation='nearest', cmap=plt.cm.gray)
        else:
            ax.imshow(mat, interpolation='nearest', cmap=plt.cm.gray, vmin=0)
        ax.set_ylabel('{}'.format(glom))
        ax.set_yticks([])
        ax.set_xticks([])
        ax.set_xlabel('{:.2f}'.format(np.max(mat)))
    fig.subplots_adjust(hspace=0.4)