Logarithmic Linear Regression

I am trying to plot a linear regression on a logarithmic scale and am not quite sure how to do it.
I used examples that I had found online but the linear regression line doesn't plot the same on a
logarithmic scale. Can anyone help me? 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), (1000000.0, 78571.399999999994), (0.93820000000000003, 1.4666699999999999),
(3.0781000000000001, 2.8571399999999998), (64.768000000000001, 78571.399999999994),
(42.656999999999996, 10576.9), (11.473000000000001, 193.05000000000001), (173.90000000000001,
14.666700000000001), (2815.1999999999998, 16.8933), (78387.0, 78571.399999999994), (31665.0,
78571.399999999994), (1000000.0, 4000.0), (59298.0, 2638.8499999999999), (13179.0, 25000.0),
(1496.9000000000001, 188.08199999999999), (815.99000000000001, 24.601900000000001),
(386.07999999999998, 68750.0), (273750.0, 34896.800000000003), (28435.0, 25000.0),
(9699.2000000000007, 25000.0), (13515.0, 40000.0), (19219.0, 25000.0), (379170.0, 25000.0),
(379560.0, 78571.399999999994), (427.58999999999997, 25000.0), (638.86000000000001, 25000.0),
(89046.0, 25000.0), (151440.0, 25000.0), (1602.5, 25000.0), (4242.8000000000002, 25000.0),
(118700.0, 25000.0), (11454.0, 5500.0), (4094.5, 511.62799999999999), (17730.0, 25000.0),
(754.64999999999998, 1692.3099999999999), (2183.9000000000001, 25000.0), (192330.0, 25000.0),
(241170.0, 25000.0), (1.4981, 7.2522099999999998), (9.3475999999999999, 147.07400000000001),
(14.512, 5.4083300000000003), (194.66999999999999, 152.30199999999999), (10.856999999999999,
7.9026300000000003), (5.1627999999999998, 94.151399999999995), (1000000.0, 53658.5),
(912.51999999999998, 448.98000000000002), (18511.0, 25000.0), (1870.7, 6027.3999999999996),
(2665.5999999999999, 10138.200000000001), (14708.0, 55000.0), (38.012, 222.988),
(295.61000000000001, 44898.0), (5.4006999999999996, 6.6227600000000004), (1000000.0,
78571.399999999994), (1000000.0, 2050.3299999999999), (1549.5, 25000.0), (19.260999999999999,
13.0), (16.82, 3.5536300000000001), (67.953999999999994, 83.956599999999995), (1651.2,
3384.6199999999999), (104.84999999999999, 38.357599999999998), (1435.2, 10091.700000000001),
(78.744, 27.834), (351.27999999999997, 28.004100000000001), (27.716000000000001,
68.239699999999999), (380.61000000000001, 25000.0), (423.26999999999998, 5500.0), (342660.0,
155000.0), (60756.0, 25000.0), (155060.0, 25000.0), (1000000.0, 78571.399999999994),
(228.90000000000001, 40.740699999999997), (1355.5, 25000.0), (4744.1999999999998,
1235.0799999999999), (1000000.0, 43239.5), (5800.6000000000004, 78571.399999999994),
(73.650000000000006, 15.1372), (66.897999999999996, 666.66700000000003), (16031.0, 25000.0),
(82.275000000000006, 78571.399999999994), (1000000.0, 25000.0), (3287.6999999999998, 25000.0),
(418600.0, 78571.399999999994), (126.83, 1739.1300000000001), (139.5, 37288.099999999999),
(13376.0, 25000.0), (268.54000000000002, 25000.0), (175630.0, 25000.0), (29286.0,
78571.399999999994), (405.25, 1.0), (2048.8000000000002, 25000.0), (1569.0999999999999,
63.398800000000001), (1378.5, 70967.699999999997), (16883.0, 25000.0), (3467.3000000000002,
25000.0), (138140.0, 78571.399999999994), (24807.0, 523.80999999999995), (434.27999999999997,
7.0816499999999998), (31013.0, 25000.0), (48096.0, 78571.399999999994), (1510.3, 1093.98),
(1574.4000000000001, 3283.5799999999999), (7285.5, 880.0), (9767.5, 12500.0), (1000000.0,
78571.399999999994), (6.4268000000000001, 314.0), (22.384, 36.363399999999999),
(46.899999999999999, 5.2683299999999997), (347.31, 220.0), (66.600999999999999,
165.83099999999999), (1361.5999999999999, 78571.399999999994), (436640.0, 4782.6099999999997),
(171290.0, 57032.300000000003), (52.948999999999998, 29733.299999999999), (192.00999999999999,
329.0), (1171.4000000000001, 3666.6700000000001), (474.16000000000003, 782.64300000000003),
(42.241, 1.99908), (184960.0, 25000.0), (1867.2, 15714.299999999999), (5690.5, 2480.0),
(3382.5999999999999, 1157.8900000000001), (1000000.0, 78571.399999999994), (1301.2,
372.62900000000002), (1608.8, 25000.0), (98.102999999999994, 57.258899999999997), (42922.0,
78571.399999999994), (3068.0999999999999, 1.0621700000000001), (210.25999999999999, 16176.5),
(611.63999999999999, 31884.099999999999), (211700.0, 78571.399999999994), (11631.0,
240.30600000000001), (1798.0999999999999, 654.76199999999994), (67.960999999999999,
17728.099999999999), (23457.0, 25000.0), (2092.0999999999999, 25000.0), (3984.8000000000002,
25000.0), (1000000.0, 78571.399999999994), (4816.3000000000002, 25000.0), (20144.0, 25000.0),
(1000000.0, 70967.699999999997), (34961.0, 6287.0), (276.86000000000001, 767.16999999999996),
(1000000.0, 70967.699999999997), (665.45000000000005, 1398.5999999999999), (650750.0,
78571.399999999994), (15336.0, 5500.0), (1000000.0, 78571.399999999994), (167.88,
733.33299999999997), (19191.0, 4.3558700000000004), (15329.0, 956.52200000000005), (922060.0,
25000.0), (1000000.0, 78571.399999999994), (1000000.0, 2885.8499999999999), (235890.0, 25000.0),
(1000000.0, 78571.399999999994), (29382.0, 78571.399999999994), (128.03999999999999, 2219.98),
(100.16, 708.53499999999997), (585.59000000000003, 17322.799999999999), (1000000.0,
78571.399999999994), (268.68000000000001, 20.957599999999999), (73322.0, 25000.0), (112410.0,
25000.0), (7489.1000000000004, 25000.0), (2382.4000000000001, 31.6875), (260540.0,
78571.399999999994), (518.32000000000005, 25000.0), (1000000.0, 25000.0), (1000000.0,
10051.299999999999), (1000000.0, 25000.0), (89655.0, 25000.0), (818.88, 25000.0), (759950.0,
25000.0), (46101.0, 18837.200000000001), (79.030000000000001, 5.5999999999999996),
(339.06999999999999, 5500.0), (3427.6999999999998, 25000.0), (126660.0, 4174.5699999999997),
(26801.0, 25000.0), (980.72000000000003, 293333.0), (136190.0, 25000.0), (3505.9000000000001,
742.24000000000001), (33.753, 222.51400000000001), (436760.0, 25000.0), (135.43000000000001,
25000.0), (305.18000000000001, 25000.0), (1349.0999999999999, 25000.0), (12096.0,
758.62099999999998), (1000000.0, 44898.0), (240.83000000000001, 20.0), (134.13,
50.645099999999999), (35997.0, 25000.0), (1000000.0, 78571.399999999994), (7.2370000000000001,
2.2916699999999999), (600.94000000000005, 19.6416), (13117.0, 4150.9399999999996),
(1188.0999999999999, 78571.399999999994), (799680.0, 78571.399999999994), (14954.0,
78571.399999999994), (479.23000000000002, 25000.0), (7310.8000000000002, 1050.6199999999999),
(1000000.0, 234.24199999999999), (12.324, 2.5555300000000001), (414240.0, 25000.0), (16625.0,
25000.0), (10895.0, 60.009999999999998), (241.34999999999999, 796.81299999999999), (1000000.0,
25000.0), (11247.0, 1692.3099999999999), (13030.0, 25000.0), (59775.0, 78571.399999999994),
(2506.5999999999999, 160.0), (9283.2999999999993, 25000.0), (1000000.0, 78571.399999999994),
(1000000.0, 78571.399999999994), (1000000.0, 9909.9099999999999), (932.30999999999995,
14.982100000000001), (2996.3000000000002, 1375.0), (1000000.0, 78571.399999999994),
(6337.1000000000004, 27500.0), (267.69, 787.68299999999999), (7534.5, 25000.0),
(4675.8999999999996, 27.0943), (1057.2, 3.7930999999999999), (5138.0, 25000.0), (36588.0,
58688.699999999997), (1000000.0, 78571.399999999994), (148.02000000000001, 2.6151200000000001),
(473.39999999999998, 36.369), (1000000.0, 78571.399999999994), (4123.1000000000004,
1973.0899999999999), (554500.0, 78571.399999999994), (1000000.0, 25000.0), (13519.0, 26445.0),
(533.91999999999996, 22000.0), (189.97999999999999, 3.8650000000000002), (73.228999999999999,
27848.099999999999), (697.75999999999999, 1000.0), (145420.0, 78571.399999999994),
(8319.2000000000007, 22000.0), (6829.3000000000002, 8.2332999999999998), (3313.8000000000002,
17600.0), (4224.8000000000002, 1294.1199999999999), (1705.8, 25000.0), (49627.0,
70967.699999999997), (125460.0, 78571.399999999994), (11.382999999999999, 7.9088900000000004),
(153.88, 71.488900000000001), (49.518999999999998, 25000.0), (8976.7999999999993, 25000.0),
(377.97000000000003, 607.06399999999996), (202910.0, 19674.200000000001), (395.48000000000002,
2109.3000000000002), (23.899999999999999, 29.602499999999999), (1000000.0, 25000.0), (159980.0,
550.0), (11661.0, 25000.0), (6065.0, 25000.0), (1000000.0, 11399.0), (540.85000000000002,
1571.4300000000001), (886.70000000000005, 767.35299999999995), (315.69, 62857.0), (3640.0, 427.0),
(2753.3000000000002, 25000.0), (1000000.0, 78571.399999999994), (1000000.0, 25000.0),
(83.905000000000001, 18032.799999999999), (1220.9000000000001, 29.352499999999999),
(1357.4000000000001, 63.269300000000001), (4245.1999999999998, 19550.900000000001),
(969.55999999999995, 25000.0), (1482.9000000000001, 758.62099999999998), (5051.3999999999996,
17632.599999999999), (580.74000000000001, 75.862099999999998), (79868.0, 2696.0799999999999),
(42.079999999999998, 1.0), (9.0183999999999997, 5.9118700000000004), (45.177, 3379.4200000000001),
(881.97000000000003, 84.410899999999998), (1245.2, 5138.4799999999996), (2044.4000000000001,
8429.1200000000008), (3889.6999999999998, 78571.399999999994), (292.23000000000002, 25000.0),
(51.344999999999999, 3.1993499999999999), (21.702999999999999, 25.287400000000002),
(4552.6999999999998, 25000.0), (12536.0, 197.983), (65.808999999999997, 105.723),
(2555.0999999999999, 25000.0), (539.64999999999998, 5500.0), (112.56, 6267.8299999999999),
(2950.6999999999998, 25000.0), (3805.8000000000002, 7333.3299999999999), (883.62,
209.18600000000001), (455.74000000000001, 12.0718), (294.00999999999999, 889.0),
(11.066000000000001, 31.7607)]

x = [f[0] for f in prediction_experiment]
y = [z[1] for z in prediction_experiment]

x = array(x)
y = array(y)

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

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, 'bs', x, m*x+b, 'r-', linewidth=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()

···

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