On Mon, 7 Mar 2011 09:25:23 -0600
Benjamin Root <[email protected]> wrote:
> The problem is that you are creating your figure wrong. Try this:
>
> import matplotlib as mpl
> mpl.use("Agg")
> import matplotlib.pyplot as plt
>
> fig = plt.figure(figsize=(20, 20))
> ax = fig.add_subplot(111)
> ax.set_title("Subtitle")
> ax.plot([1, 2, 3], [3, 2, 1])
> st = fig.suptitle("Horray!", fontsize=20)
> fig.savefig("out.png", bbox_inches='tight', bbox_extra_artists=[st])
>
> Notice that I am using the pyplot interface. Matplotlib was intended to be
> used through either this pyplot interface or the pylab interface (which I do
> not personally recommend if you want full control over your plots). If you
> don't use either interfaces, then don't be surprised when things do not work
> properly. In particular, creating the figure object by directly calling the
> Figure constructor bypasses important steps that involves attaching the
> appropriate backend to the figure object.
I was reading this at the time:
http://matplotlib.sourceforge.net/faq/usage_faq.html
I inferred pyplot was just a matlab-like interface on top of matplotlib, and
figured using directly the matplotlib was acceptable.
Reading the documentation of the single objects of matplotlib was enough to get
me started. I see pyplot as having more shortcuts for common operations, but I
was unsure how far can I could go by using pyplot only.
Generally, I didn't have any trouble. The includes are a bit verbose, but
that's it.
> Also notice that I name the object coming from add_subplot() "ax" instead of
> "plot". This is for clarity and to avoid confusion with the command
> "plot". This is also the generally accepted coding convention in
> matplotlib.
Indeed, thanks for the remark.
Thanks again for your comments.
------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users