1. I added the following at the end of the script just
> before show savefig("filename")
> It works however the intereactive mode still comes up. How
> can I generate the image file without having the
> interactive window come up.
Hi Vineet,
This is because you are using the TkAgg backend. This is the default
backend for win32 users. You set the default backend in your
.matplotlibrc file, which is located in
C:\python23\share\matplotlib\.matplotlibrc for a standard win32
install. For pure image generation, you probably want to choose Agg
as the default backend. There are a number of ways of setting the
backend at runtime, as described at
http://matplotlib.sourceforge.net/backends.html
> 2. figure(1, facecolor=figBG) What is this used for? Is it
> for the interactive charting? I can still generate charts
> to file with this commented.
Here is a little background. You can use the functions figure,
subplot, and axes to explicitly control this figure and axes creation.
If you don't use them, defaults will be issued for you. Let's take a
look at what happens under the hood when you issue the commands
>>> from matplotlib.matlab import *
>>> plot([1,2,3])
When plot is called, the matlab interface makes a call to gca() "get
current axes" to get a reference to the current axes. gca in turn,
makes a call to gcf() to get a reference to the current figure. gcf,
finding that no figure has been created, creates the default figure
with figure() and returns it. gca will then return the current axes
of that figure if it exists, or create the default axes
subplot(111) if it does not. Thus the code above is equivalent
to
>>> from matplotlib.matlab import *
>>> figure()
>>> subplot(111)
>>> plot([1,2,3])
The only time you need to manually call figure, subplot and axes are
when 1) you want to manage multiple figures and axes, or 2) you want
to change the default parameters (sizes, locations, colors, etc).
> 3. Where and how do you set the overall size of the chart
> ( in inches or pixels)
The figsize kwarg to figure sets the figure size in inches. The dpi
specifies the dots per inch. The figure width in pixels is thus the
figsize width component time the dpi. You can set these as kwargs to
the figure command - see
http://matplotlib.sf.net/matplotlib.matlab.html#-figure or by setting
the defaults in your rc file in the section
### FIGURE
figure.figsize : 8, 6 # figure size in inches
figure.dpi : 80 # figure dots per inch
figure.facecolor : 0.75 # figure facecolor; 0.75 is scalar gray
figure.edgecolor : w # figure edgecolor; w is white
Note that the rc allows different defaults for savefig, which are
given by
savefig.dpi : 100 # figure dots per inch
savefig.facecolor : w # figure facecolor; 0.75 is scalar gray
savefig.edgecolor : w # figure edgecolor; w is white
Cheers,
JDH