# Customize the plot ax.grid(1, ls='--', color='#777777', alpha=0.5, lw=1) ax.tick_params(labelsize=12, length=0) ax.set_axis_bgcolor('w') # add a legend leg = plt.legend( ['text'], loc=1 ) fr = leg.get_frame() fr.set_facecolor('w') fr.set_alpha(.7) plt.draw()