On Fri, 4 Mar 2011 14:57:34 -0600
Benjamin Root <ben.r...@ou.edu> wrote:

> Which version of matplotlib are you using?  This example works for me using
> the latest matplotlib from source.  Also, why the awkward usage and

Yes, with matplotlib 1.0 bbox_extra_artists now works.

I consider bbox_extra_artists some kind of a hack (IMHO, all artists should be 
considered with a 'tight' box), but coming from gnuplot/asymptote maybe my 
point of view is biased.
What would be the point of a 'tight' box that excludes parts of the plot? I 
would specify the coordinates myself if I needed clipping.

> imports?  If you want to force the Agg backend to be used, you could just
> do:
> 
> import matplotlib
> matplotlib.use("Agg")
> 
> before any other matplotlib imports.

Thanks for the suggestion, that looks promising, but doesn't work:

----
import matplotlib as mpl
mpl.use("Agg")
import matplotlib.figure
fig = mpl.figure.Figure()
fig.set_size_inches((20,20))
plot = fig.add_subplot(111)
plot.set_title("Subtitle")
plot.plot([1,2,3], [3,2,1])
st = fig.suptitle("Horray!", fontsize=20)
fig.savefig("out.png", bbox_inches='tight', bbox_extra_artists=[st])
----

produces:

Traceback (most recent call last):
  File "test.py", line 13, in <module>
    fig.savefig("out.png", bbox_inches='tight', bbox_extra_artists=[st])
  File "/usr/lib/pymodules/python2.6/matplotlib/figure.py", line 1084, in 
savefig
    self.canvas.print_figure(*args, **kwargs)
AttributeError: 'NoneType' object has no attribute 'print_figure'

I find the documentation a bit scattered around this subject.
I'm not using the pyplot interface, so I guess that .use("Agg") doesn't do 
anything for me?
I also have no reason to use the pyplot interface, why should I? I have no 
matlab background, and I mostly use matplotlib procedurally (ie not 
interactively).


------------------------------------------------------------------------------
What You Don't Know About Data Connectivity CAN Hurt You
This paper provides an overview of data connectivity, details
its effect on application quality, and explores various alternative
solutions. http://p.sf.net/sfu/progress-d2d
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to