xticks label rotation removes axes xlabel

If I rotate the xticks labels on this scatter plot the axes label is pushed off the figure. Do I
need to make the figuresize bigger or is matplotlib calculating it incorrectly?

from pylab import *

prediction_experiment = [(0.0001, 0.0001),(2, 250.797999999999998), (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 roundUpLogDecade(x):
    """ Round up to the nearest logarithmic decade"""
    return math.ceil(x)

def roundDownLogDecade(x):
    """ Round up to the nearest logarithmic decade"""
    return math.floor(x)

def integer(x, pos):
    if x >= 1:
       return '%i' % (int(x))
        return '%.4f' % x

auc_cutoff = 50

ax = subplot(111)
# Axis scale must be set prior to declaring the Formatter
# If it is not the Formatter will use the default log labels for ticks.

formatter = FuncFormatter(integer)

tp_prediction_experiment = [[x[0], x[1]] for x in prediction_experiment if x[1] < auc_cutoff]
tn_prediction_experiment = [[x[0], x[1]] for x in prediction_experiment if x[1] > auc_cutoff]

ax.scatter( [x[0] for x in tn_prediction_experiment], [x[1] for x in tn_prediction_experiment],
s=3, c='r', marker='s', faceted=False)
ax.scatter( [x[0] for x in tp_prediction_experiment], [x[1] for x in tp_prediction_experiment],
s=3, c='b', marker='s', faceted=False)

# Must add 1 to allow the last decades label to be shown
ax.set_xlim(10**roundDownLogDecade(log10(min([x[0] for x in prediction_experiment]))),
10**roundUpLogDecade(log10(max([x[0] for x in prediction_experiment])))+1)
ax.set_ylim(10**roundDownLogDecade(log10(min([x[1] for x in prediction_experiment]))),
10**roundUpLogDecade(log10(max([x[1] for x in prediction_experiment])))+1)
xlabel(r"Prediction", fontsize = 12)
ylabel(r"Experimental IC50 [nM]", fontsize = 12)

xlocs, xlabels = xticks()
setp(xlabels, rotation=45)
ylocs, ylabels = yticks()
setp(ylabels, rotation=45)


Derek Basch


Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around