[Matplotlib-users] Invalid (trancated) PDFs in Web application

2008-10-11 Thread Torsten Bronger
Hallöchen!

I generate PDFs of scientific data with Matplotlib.  This is done
automatically within a Web application written with Django.  I
generate a PNG thumbnail, too, which always is correct, however, the
PDF is truncated in most cases.

Now I wonder whether it may be a timeout by the Web server or Django
itself.  Thus, if Matplotlib takes too long (maybe due to cuncurrent
processes), it cannot write the full PDF.  However, if it fails, the
truncation happens always at the same point in the file.

Here's a good PDF:
http://www-users.rwth-aachen.de/torsten.bronger/pds_okay.pdf

And this is the truncated version:
http://www-users.rwth-aachen.de/torsten.bronger/pds_truncated.pdf

Thus, this is the trailing part which is missing:
http://www-users.rwth-aachen.de/torsten.bronger/pds_missing.txt

Does anybody has an idea at which point and why Matplotlib stops
working?

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
   Jabber ID: [EMAIL PROTECTED]


-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK  win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Invalid (trancated) PDFs in Web application

2008-10-11 Thread Jouni K . Seppänen
Torsten Bronger [EMAIL PROTECTED] writes:

 Thus, this is the trailing part which is missing:
 http://www-users.rwth-aachen.de/torsten.bronger/pds_missing.txt

 Does anybody has an idea at which point and why Matplotlib stops
 working?

The missing parts are the xref table and the trailer, which are written
by functions called by close():

def close(self):
# End the content stream and write out the various deferred
# objects
self.endStream()
  ...
self.writeImages()
self.writeMarkers()
self.writeXref()
self.writeTrailer()
if not self.passed_in_file_object:
self.fh.close()

So it looks like writeMarkers() has been called but writeXref() has not. 

-- 
Jouni K. Seppänen
http://www.iki.fi/jks


-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK  win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Invalid (trancated) PDFs in Web application

2008-10-11 Thread Jouni K . Seppänen
Jouni K. Seppänen [EMAIL PROTECTED] writes:

 Torsten Bronger [EMAIL PROTECTED] writes:

 Does anybody has an idea at which point and why Matplotlib stops
 working?
...
 if not self.passed_in_file_object:
 self.fh.close()

I wonder if we should flush a file object that was passed in... Could
you check if the following patch (committed on the trunk) helps with
your problem?

Index: lib/matplotlib/backends/backend_pdf.py
===
--- lib/matplotlib/backends/backend_pdf.py	(revision 6178)
+++ lib/matplotlib/backends/backend_pdf.py	(revision 6179)
@@ -446,7 +446,9 @@
 self.writeMarkers()
 self.writeXref()
 self.writeTrailer()
-if not self.passed_in_file_object:
+if self.passed_in_file_object:
+self.fh.flush()
+else:
 self.fh.close()
 
 def write(self, data):

-- 
Jouni K. Seppänen
http://www.iki.fi/jks
-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK  win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100url=/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Invalid (trancated) PDFs in Web application

2008-10-11 Thread Torsten Bronger
Hallöchen!

Jouni K. Seppänen writes:

 Jouni K. Seppänen [EMAIL PROTECTED] writes:

 Torsten Bronger [EMAIL PROTECTED] writes:

 Does anybody has an idea at which point and why Matplotlib stops
 working?

 ...
 if not self.passed_in_file_object:
 self.fh.close()

 I wonder if we should flush a file object that was passed in... Could
 you check if the following patch (committed on the trunk) helps with
 your problem?

 [...]

Yes, it solves my problem.

Apparently, if you wait long enough, the rest of the file is indeed
written.  However, with your patch, I see the whole file
immediately, which is much better in the multi-processes environment
of an Apache server.  Thank you!

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
   Jabber ID: [EMAIL PROTECTED]


-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK  win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] plot chops off big Latex axis labels

2008-10-11 Thread chris
The plot PDFs that matplotlib makes by default seem to be too tiny to contain
my biggest axis labels and my poor Latex stuff is chopped in half.

How fix?

cs

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK  win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users