def legend(self, **kwargs): """ Adds a legend to the plot. """ if not hasattr(self, 'barlist'): args = (('Global', 'Cold', 'Neutral', 'Warm'),) else: args = (self.barlist, ('Global', 'Cold', 'Neutral', 'Warm'),) Subplot.legend(self, *args, **kwargs)
def _draw_legend(subplot: plt_axes.Subplot): nucleotide_patches, nucleotide_class_names_with_names = ( subplot.figure.gca().get_legend_handles_labels()) nucleotide_class_names = [ each_class_name_with_name.split(":")[0] for each_class_name_with_name in nucleotide_class_names_with_names] legend_labels, legend_items = zip(*OrderedDict( zip(nucleotide_class_names, nucleotide_patches)).items()) subplot.legend(legend_items, legend_labels, loc="lower right", bbox_to_anchor=(0, 0), title="Nucleotide types")
def legend(self, **kwargs): """ Adds a legend to the plot. """ if not hasattr(self, 'barlist'): args = (('Global', 'Cold', 'Neutral', 'Warm'), ) else: args = ( self.barlist, ('Global', 'Cold', 'Neutral', 'Warm'), ) Subplot.legend(self, *args, **kwargs)
def plot_chem_shift_dist(title,residues, amino_acids): three_lets = [aa.three_let for aa in amino_acids] nuclei = ['CO', 'CA', 'CB', 'CG', 'CG1', 'CG2', 'CD', 'CD1', 'CD2', 'CE', 'CE1', 'CE2', 'CE3', 'CZ', 'CZ2', 'CZ3', 'CH2'] colors = ['b','g','r','c','c','c', 'm','m','m','y','y','y', 'y','gray','gray','gray','k'] means, stds = data_array(amino_acids, nuclei) fig = pl.figure() ax = Subplot(fig,111) ax = pl.gca() fig.add_subplot(ax) x = means # print nan_to_num(x) y = ones(x.shape) for i in range(0,x.shape[0]): y[i]*=i for j in range(0,x.shape[1]): ax.errorbar(x.T[j], y.T[j], xerr=nan_to_num(stds.T[j]), linestyle='None',marker='o', color=colors[j], label=(nuclei[j]), linewidth=4, capsize=20) for r in residues: x = ones_like(means)*nan name = r.name shifts, atoms = r.get_carbons(previous=False) for shift,atom in zip(shifts,atoms): if atom in nuclei: j = nuclei.index(atom) # if name != "NAA": # name = one2Three(r.name[0]) i = three_lets.index(name) x[i][j] = shift for j in range(0,x.shape[1]): ax.plot(x.T[j],y.T[j], marker="x",linestyle="None", color=colors[j],markersize=15) pl.yticks(arange(0,20), three_lets) pl.ylim(-1,20) pl.title('Verteilung chemischer Verschiebungen\n %s'%title) pl.ylabel('Aminosaeure') pl.xlabel('ppm') pl.rcParams.update({'font.size': 22}) # Shink current axis by 20% box = ax.get_position() ax.set_position([box.x0, box.y0, box.width * 0.8, box.height]) # Put a legend to the right of the current axis ax.legend(loc='center left', bbox_to_anchor=(1, 0.5)) pl.show()