Q:

Incorrectly placed legend in python pandas

I am using the foll. code to plot legend in python pandas , but it is not showing up correctly:
# Create plot
fig = plt.figure()
plt.rc('legend',**{'fontsize':8})
ax = df.resample('M', how='mean').plot(colormap=cols)

# Create a legend with transparent box around it
leg = plt.legend(fancybox = None, bbox_to_anchor=(0.5, -0.02), ncol=3)
leg.get_frame().set_linewidth(0.5)
leg.get_frame().set_alpha(0.5)
ax.set_ylabel('Percentiles')

# Place legend in right place and output
fig.subplots_adjust(bottom=0.2)

How do I fix this? I want legend to be outside of plot but visible and not partly cut off.

A:

The second parameter in bbox_to_anchor controls the y-axis. Try changing it, e.g.:
leg = plt.legend(fancybox = None, bbox_to_anchor=(0.5, -0.04), ncol=3)

