From: Gökhan S. <gok...@gm...> - 2011-02-10 23:52:05
|
Hi, I would simply try to attach the legend to the figure object instead of the axis. On Thu, Feb 10, 2011 at 4:20 PM, Jeff Layton <lay...@at...> wrote: > Good evening, > > I've been trying to find a way to move the legend outside > the plot so it doesn't cover it up. I've seen some things > online but I can quite get them to work (probably just my > lack of knowledge about matplotlib). > > The section of code creating the plot looks like, > > fig = plt.figure() > ax = fig.add_subplot(1,1,1); > > p1 = ax.bar(ind, IO_Time_Plot, width, color="r", align='center'); > p2 = ax.bar(ind, Diff_Plot, width, color="y", > bottom=IO_Time_Plot, align='center'); > > ax.set_ylabel('Time (secs)'); > ax.set_title('Elapsed Time and IO Time',fontstyle='italic'); > ax.set_xticks(ind); > > group_labels = []; > for item in names: > group_labels.append(item); > > ax.set_xticklabels(group_labels); > > fig.autofmt_xdate(); > > #ax.legend( bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.); > ax.legend( (p1[0], p2[0]), ('IO Time', 'Total Elapsed Time')); > > > > You can see my attempt at moving the legend outside the bounding box > but when I try this, the legend never appears. > > TIA! > > Jeff > > > > > ------------------------------------------------------------------------------ > The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE: > Pinpoint memory and threading errors before they happen. > Find and fix more than 250 security defects in the development cycle. > Locate bottlenecks in serial and parallel code that limit performance. > http://p.sf.net/sfu/intel-dev2devfeb > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- Gökhan |