def plotCorrelation(self, x, y, labels=None, key='Mutations', title='', xlabel='Predicted', ylabel='Experimental', ms=5, err=None, axeslabels=True, plotname=None, stats=True, side=LEFT, ax=None): """Show exp vs pred. for a set of x-y values """ #check if x and y are number cols and round x = [round(float(i), 2) for i in x] y = [round(float(i), 2) for i in y] if min(x) < min(y): a = min(x) - 2 else: a = min(y) - 4 if max(x) > max(y): b = max(x) + 2 else: b = max(y) + 4 colors = ['b', 'g', 'r', 'y', 'm', 'c'] if ax == None: fig = plt.figure(figsize=(6, 6)) ax = fig.add_subplot(111) else: #fig = ax.get_figure() fig = None if axeslabels == True: ax.set_xlabel(xlabel) ax.set_ylabel(ylabel) legs = [] legnames = [] bad = [] good = [] if len(x) == 0: return errs = [i - j for i, j in zip(x, y)] line = ax.plot(x, y, 'o', mew=0, ms=ms, alpha=0.6, label=plotname, picker=3) #draw expected correlation line with slope x slope = 1 #set range of axes ax.plot((a, b), (a, b), 'g') ax.axhline(y=0, color='grey') ax.axvline(x=0, color='grey') ax.set_xlim(a, b) ax.set_ylim(a, b) ax.set_title(title) if err != None: ax.plot((a, b), (a + err, b + err), '--', color='g') ax.plot((a, b), (a - err, b - err), '--', color='g') if stats == True: self.addStats(ax, x, y) if fig != None: fig.suptitle('Predicted vs Experimental') from PEATDB.Actions import DBActions frame = DBActions.showTkFigure(fig, side=side) #mh = MouseHandler(ax, self, labels, key) #mh.connect() mh = self.addMouseHandler(ax, labels, key) else: mh = frame = None return ax, frame, mh
def plotCorrelation(self, x, y, labels=None, key='Mutations', title='', xlabel='Predicted', ylabel='Experimental', ms=5, err=None, axeslabels=True, plotname=None, stats=True, side=LEFT, ax=None): """Show exp vs pred. for a set of x-y values """ #check if x and y are number cols and round x=[round(float(i),2) for i in x] y=[round(float(i),2) for i in y] if min(x)<min(y): a=min(x)-2 else: a=min(y)-4 if max(x)>max(y): b=max(x)+2 else: b=max(y)+4 colors = ['b','g','r','y','m','c'] if ax==None: fig = plt.figure(figsize=(6,6)) ax = fig.add_subplot(111) else: #fig = ax.get_figure() fig = None if axeslabels==True: ax.set_xlabel(xlabel) ax.set_ylabel(ylabel) legs=[]; legnames=[] bad=[]; good=[] if len(x) ==0: return errs = [i - j for i, j in zip(x, y)] line = ax.plot(x, y, 'o', mew=0, ms=ms, alpha=0.6, label=plotname, picker=3) #draw expected correlation line with slope x slope=1 #set range of axes ax.plot((a,b),(a,b),'g') ax.axhline(y=0, color='grey'); ax.axvline(x=0,color='grey') ax.set_xlim(a,b); ax.set_ylim(a,b) ax.set_title(title) if err!=None: ax.plot((a,b),(a+err,b+err),'--',color='g') ax.plot((a,b),(a-err,b-err),'--',color='g') if stats==True: self.addStats(ax,x,y) if fig!=None: fig.suptitle('Predicted vs Experimental') from PEATDB.Actions import DBActions frame = DBActions.showTkFigure(fig, side=side) #mh = MouseHandler(ax, self, labels, key) #mh.connect() mh = self.addMouseHandler(ax, labels, key) else: mh = frame = None return ax, frame, mh