From: Vineet J. <vi...@al...> - 2004-07-20 03:39:47
|
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. 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. 3. Where and how do you set the overall size of the chart ( in inches or pixels) Thanks, Vineet |
From: John H. <jdh...@ac...> - 2004-07-20 14:38:54
|
>>>>> "Vineet" == Vineet Jain <vi...@al...> writes: Vineet> 1. I added the following at the end of the script just Vineet> before show savefig("filename") Vineet> It works however the intereactive mode still comes up. How Vineet> can I generate the image file without having the Vineet> 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 Vineet> 2. figure(1, facecolor=figBG) What is this used for? Is it Vineet> for the interactive charting? I can still generate charts Vineet> 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). Vineet> 3. Where and how do you set the overall size of the chart Vineet> ( 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 |
From: Vineet J. <vi...@al...> - 2004-07-21 04:15:37
|
Thanks for the information. It has been very helpful. Matplotlib seems to be ignoring the use command. When I change the value in .matplotlibrc it works however adding the use('Agg') does not change the backed. Do I need to do anything else? Thanks, Vineet -----Original Message----- From: mat...@li... [mailto:mat...@li...]On Behalf Of John Hunter Sent: Tuesday, July 20, 2004 9:15 AM To: Vineet Jain Cc: mat...@li... Subject: Re: [Matplotlib-users] How to run matplotlib in batch mode to generate plot image files >>>>> "Vineet" == Vineet Jain <vi...@al...> writes: Vineet> 1. I added the following at the end of the script just Vineet> before show savefig("filename") Vineet> It works however the intereactive mode still comes up. How Vineet> can I generate the image file without having the Vineet> 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 Vineet> 2. figure(1, facecolor=figBG) What is this used for? Is it Vineet> for the interactive charting? I can still generate charts Vineet> 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). Vineet> 3. Where and how do you set the overall size of the chart Vineet> ( 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 ------------------------------------------------------- This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools! Get your free copy of BEA WebLogic Workshop 8.1 today. http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click _______________________________________________ Matplotlib-users mailing list Mat...@li... https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
From: John H. <jdh...@ac...> - 2004-07-21 17:26:13
|
>>>>> "Vineet" == Vineet Jain <vi...@al...> writes: Vineet> Thanks for the information. It has been very Vineet> helpful. Matplotlib seems to be ignoring the use Vineet> command. When I change the value in .matplotlibrc it works Vineet> however adding the use('Agg') does not change the Vineet> backed. Do I need to do anything else? You must use the use command before importing matplotlib.matlab, as described on http://matplotlib.sourceforge.net/backends.html >>> import matplotlib >>> matplotlib.use('Agg') >>> from matplotlib.matlab import * Note that if you are using an IDE like pycrust, pythonwin, or IDLE, matplotlib.matlab may have already been loaded, and subsequent calls to use or 'from matplotlib.matlab import *' will have no effect unless you explicitly force a module reload. JDH |