From: Benjamin R. <ben...@ou...> - 2012-04-13 13:10:00
|
On Fri, Apr 13, 2012 at 2:21 AM, Jonathan Bruck <jdt...@gm...> wrote: > Thanks for a response, but unfortunately it doesn't seem to work. I have > some sample code on pastebin http://pastebin.com/W6JmbCsz in case the > following does not email out well > > # -*- coding: utf-8 -*- > """ > Created on Thu Apr 12 11:16:03 2012 > > Using the current stable version of pythonxy on Windows 7 32bit > Author: Jonathan > > > Notice how the figure box is not placed correctly, effectively missing the > legend entirely > """ > > import matplotlib.pyplot as plt > import numpy as np > > x = np.arange(-2*np.pi, 2*np.pi, 0.1) > fig = plt.figure(1, figsize=(8,6)) > ax = fig.add_subplot(111) > ax.plot(x, np.sin(x), label='Sine') > ax.plot(x, np.cos(x), label='Cosine') > ax.plot(x, np.arctan(x), label='Inverse tan') > handles, labels = ax.get_legend_handles_labels() > lgd = ax.legend(handles, labels, loc=9, bbox_to_anchor=(0.5,-0.1)) > ax.grid('on') > #fig.tight_layout() > fig.savefig('samplefigure', bbox_extra_artists=(lgd,), bbox='tight') > > > I apologize, it was bbox_inches='tight', not bbox='tight'. Because savefig has to be able to take arbitrary kwargs that get passed down to the backends, it does not check for incorrect kwargs. Ben Root |