 # Combining Linear and Logarithmic Plots

Hello,

I need to create a Linear Regression plot where the vertices are plotted on a logarithmic plane
and the regression line is plotted on a linear plane. The two are then combined. Here is what I
have so far:

from pylab import *

prediction_experiment = [(313.11000000000001, 25.797999999999998), (4499.1999999999998, 25000.0),
(168830.0, 440000.0), (143090.0, 78571.399999999994), (34811.0, 78571.399999999994), (161240.0,
70967.699999999997)]

def log10Product(x, pos):
"""The two args are the value and tick position.
Label ticks with the product of the exponentiation"""
return '%1i' % (x)

def generateLRPlot():

prediction_experiment.sort()

x, y = map(array, zip(*prediction_experiment))

ax = subplot(111)

ax.set_xscale('log')
ax.set_yscale('log')

formatter = FuncFormatter(log10Product)
ax.xaxis.set_major_formatter(formatter)
ax.yaxis.set_major_formatter(formatter)

# the bestfit line from polyfit
m, b = polyfit(x, y, 1) # a line is 1st order polynomial...

plot(x, y, 'b.', x, m*x+b, 'r', linewidth=0.1, markersize=2)

# Must add 1 to allow the last decades label to be shown
ax.set_xlim(1e-1, max(x)+1)
ax.set_ylim(1e-1, max(y)+1)
grid(True)
xlabel(r"Prediction", fontsize = 12)
ylabel(r"Experimental IC50 [nM]", fontsize = 12)
show()
# clear the matplotlib figure and axis
clf()
cla()

generateLRPlot()

Thanks for the help,
Derek Basch

···

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com