From: John H. <jdh...@ac...> - 2004-01-26 06:30:00
|
>>>>> "Kuzminski," == Kuzminski, Stefan R <SKu...@fa...> writes: Kuzminski> I attached a '_gd.dll'. This is the C python Kuzminski> extension that the gd.py module from gdmodule imports. Kuzminski> It goes directly in site-packages. I built it Kuzminski> statically linked to zlib, libpng, freetype and the gd Kuzminski> lib. I don't have the time at the moment to fuss with Kuzminski> getting it to use the dlls. ( or to add the jpeg Kuzminski> support ) The precompiled windows GD dll in particular Kuzminski> seems to not export a few functions that gdmodule Kuzminski> wants which is a real pain. Excellent, the easier the better... Kuzminski> 2) This one took me a long time to figure out. For Kuzminski> some reason opening a windows file in Python with 'wb' Kuzminski> permission will cause the png files to be corrupted Kuzminski> above a certain image size. If you pass the filename Kuzminski> to gdmodule, then the gdmodule opens the file and it Kuzminski> works. I imagine that the python call "open( Kuzminski> 'filename', 'wb' )" just calls fopen, furthermore I Kuzminski> thought that binary mode only applied to reading Kuzminski> files. At any rate, I have no idea why this doesn't Kuzminski> work in this case but it doesn't. To get it to work, Kuzminski> I had to change line 261 in backends_gd.py to pass the Kuzminski> filename rather than a file object, this is the only Kuzminski> modification to Matplotlib I had to make. Could be that I don't have the text bounding boxes exactly right in gdmodule. In axes.py there is a line on or around line 454 if 0: if you replace that with if 1: the text bounding boxes will be displayed. If they are not exactly right, then the text layout will also be off. I'll take a look when I get some time, but in the mean time you may want to see for yourself. Re: gdmodule on windows. What did you do for fonttools? Did you also build this yourself? If I recall correctly I built it once on windows without too much difficulty (back when I was trying to get gd working on windows) but it's been a while and I didn't keep notes. I didn't see an installer on the sf site. JDH Kuzminski> im.writePng( filename ) Kuzminski> #2 above is the answer to the problem in my original Kuzminski> post. However I have another question. When I set the Kuzminski> ylabel rotation to be horizontal, the beginning of the Kuzminski> text is truncated ( the width of the border does not Kuzminski> compensate ). I'm happy to set it wider but am Kuzminski> wondering how ( what controls the width of the area Kuzminski> where the labels gets written ). I also noticed that Kuzminski> title of the graph ( with the horizontal alignment set Kuzminski> to bottom ) is too close to the top of the graph Kuzminski> itself, is there a way to pad that? Kuzminski> thanks, Stefan Kuzminski> -----Original Message----- From: John Hunter Kuzminski> [mailto:jdh...@ni...] Sent: Kuzminski> Friday, January 23, 2004 6:58 AM To: Kuzminski, Stefan Kuzminski> R Cc: mat...@li... Subject: Kuzminski> Re: [Matplotlib-users] broken PNG files with GD Kuzminski> backend >>>>> "Kuzminski," == Kuzminski, Stefan R <SKu...@fa...> Kuzminski> writes: Kuzminski> Now on to my specific problem. I'm using the GD Kuzminski> backend on Windows with Matplotlib 0.41. Kuzminski> First things first -- I haven't succeeded in getting Kuzminski> the gd backend compiled on windows. If you have some Kuzminski> expertise here and are willing to share, or better yet Kuzminski> build a gdmodule and gd installer that I can put on Kuzminski> the website, I would be very much obliged! I Kuzminski> contacted the gdmodule maintainer some time ago over Kuzminski> this issue and he had never built it on windows Kuzminski> either. In my googling, I discovered the perl gd Kuzminski> module for windows and following their lead, succeeded Kuzminski> in building gd lib, but ran into some troubles (can't Kuzminski> remember what) building gdmodule. Kuzminski> If I set the dpi to over 60 the png file that gets Kuzminski> generated is 'empty', it's only 17 bytes long. As soon Kuzminski> as I drop he DPI to below 65 or so, I get the image Kuzminski> file correctly. This is with the simple_plot.py Kuzminski> example. Kuzminski> Now on to your problem. Is there a typo here? You say Kuzminski> over 60 is empty and under 65 is ok ?? Can you send Kuzminski> me a script which replicates the problem, with the two Kuzminski> calls to savefig, one which has the problem and which Kuzminski> does not. Then I can begin to diagnose the problem; Kuzminski> see if it occurs under linux, see if it's a gd Kuzminski> problem, see if it's a problem on my end, etc.... Kuzminski> Are you using matplotlib + GD for a web app server? Kuzminski> John Hunter |
From: Kuzminski, S. R <SKu...@fa...> - 2004-01-29 07:08:53
|
The windows GD build is bear. I had it completely working, then I upgraded to 0.41 and took a few steps back. =20 First a little background. I'm building a reporting tool for a commercial analytics platform. This tool takes an XML specification and data, and outputs HTML tables and plots. The larger platform is all Java, I am providing the reporting as an stand alone ( Python ) executable on Win32, Linux and Solaris. So my overall requirements are to create HTML ( and hence .png images ) on all three platforms with a distribution of a single binary file ( one for each platform ). Here are some quick notes on what I have had to do, once it is working, I will provide at least the MSVC makefiles an maybe a binary build, time permitting. =20 the GD backend has these dependencies.. libpng zlib gd freetype gdmodule The 2 main problems I seem to have are that the dll release of GD does not include a gd.lib. ( MSVC needs a .lib to link with a .dll ) GD does not seem to come with a windows make file, so I made one. =20 The other problem is that _gdmodule.c needs to have line 1882 changed to pass a NULL to PYObject_HEAD_INIT=20 ... static PyTypeObject Imagetype =3D { PyObject_HEAD_INIT(NULL) ... I am working on this currently and will post more results as I get them. thanks, Stefan -----Original Message----- From: John Hunter [mailto:jdh...@ni...]=20 Sent: Friday, January 23, 2004 6:58 AM To: Kuzminski, Stefan R Cc: mat...@li... Subject: Re: [Matplotlib-users] broken PNG files with GD backend >>>>> "Kuzminski," =3D=3D Kuzminski, Stefan R <SKu...@fa...> writes: Kuzminski> Now on to my specific problem. I'm using the GD Kuzminski> backend on Windows with Matplotlib 0.41. =20 First things first -- I haven't succeeded in getting the gd backend compiled on windows. If you have some expertise here and are willing to share, or better yet build a gdmodule and gd installer that I can put on the website, I would be very much obliged! I contacted the gdmodule maintainer some time ago over this issue and he had never built it on windows either. In my googling, I discovered the perl gd module for windows and following their lead, succeeded in building gd lib, but ran into some troubles (can't remember what) building gdmodule. Kuzminski> If I set the dpi to over 60 the png file that gets Kuzminski> generated is 'empty', it's only 17 bytes long. As soon Kuzminski> as I drop he DPI to below 65 or so, I get the image Kuzminski> file correctly. This is with the simple_plot.py Kuzminski> example. Now on to your problem. Is there a typo here? You say over 60 is empty and under 65 is ok ?? Can you send me a script which replicates the problem, with the two calls to savefig, one which has the problem and which does not. Then I can begin to diagnose the problem; see if it occurs under linux, see if it's a gd problem, see if it's a problem on my end, etc.... Are you using matplotlib + GD for a web app server? =20 John Hunter=20 =20 |
From: John H. <jdh...@ac...> - 2004-01-26 21:24:18
|
>>>>> "John" == John Hunter <jdh...@ac...> writes: Kuzminski> #2 above is the answer to the problem in my original Kuzminski> post. However I have another question. When I set the Kuzminski> ylabel rotation to be horizontal, the beginning of the Kuzminski> text is truncated ( the width of the border does not Kuzminski> compensate ). I'm happy to set it wider but am Kuzminski> wondering how ( what controls the width of the area Kuzminski> where the labels gets written ). In this case the placement of the ylabel is determined by the horizontalalignment and the left side of the y tick labels. If it is being truncated, you have a few choices. 1) Use a different alignment or smaller fontsize for the label 2) Use a smaller font size for the y tick labels or turn them off entirely -- the position of the ylabel will automatically adjust based upon the size of the tick labels. 3) Probably best, make a custom axes where the 'left' parameter is larger and the width parameter is smaller. This will give you more room for your ylabel. Kuzminski> I also noticed that title of the graph ( with the Kuzminski> horizontal alignment set to bottom ) is too close to Kuzminski> the top of the graph itself, is there a way to pad Kuzminski> that? When you set the title, do t = title('my title') t.set_y(1.05) # relative axes coords 1.0 is the top of the axes, so the larger the number the higher the title will be. 1.02 is the default. Hope this helps, JDH |