I realize that I have not been clear enough.

I have already created a legend instance in my_own_plot_function, for
example, a legend with one column by default: 

fig = plt.figure()
ax = fig.add_subplot(111)
my_own_plot_function(ax, data)    # gives, for example, one column
legend by default

So ax is an axes instance containing the legend.

Incidentally, after inspecting the automatically created plots, I want a
particular figure to have a two column legend. I would like to do this
without adding an extra kwarg for the number of columns to
my_own_plot_function. It should be possible to do something like this:

legend = ax.get_legend()
/legend.set_ncol(2)/          # something like this

Once again, thanks for any help!

Bram


On 02/08/2011 12:35 PM, Thomas Lecocq wrote:
> Bram,
>  
>  
> fig = plt.figure()
> ax = fig.add_subplot(111)
> plot1 = plot.plot(X,Y,label='1')
> plot2 = plot.plot(X,Y,label='2')
> ...
> plotN = plot.plot(X,Y,label='N')
>  
> legend = plt.legend(ncol=2)
>  
> should work...
>  
> so, for your "own_plot_function", you have to return the legend and
> set it accordingly...
>  
> Thomas
>  
>
>
> **********************
> Thomas Lecocq
> Geologist
> Ph.D.Student (Seismology)
> Royal Observatory of Belgium
> **********************
>
>
>  
> ------------------------------------------------------------------------
> Date: Tue, 8 Feb 2011 11:25:58 +0100
> From: sand...@knmi.nl
> To: matplotlib-users@lists.sourceforge.net
> Subject: [Matplotlib-users] set ncol for legend
>
> Hi,
>
> I want to update the number of columns in my legend. How should I do that?
>
> I'm looking for something like:
>
> fig = plt.figure()
> ax = fig.add_subplot(111)
> my_own_plot_function(ax, data)    # gives, for example, one column
> legend by default
> legend = ax.get_legend()
> /legend.set_ncol(2)/          # something like this
>
>
> However, /ncol/ is not in the legend.properties() list for properties
> to be set through legend.set.
>
>
> Thanks for any help,
> Bram
>
>
> ------------------------------------------------------------------------------
> 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 Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users 

------------------------------------------------------------------------------
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
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to