|
From: Martin M. <mm...@gm...> - 2006-07-07 16:21:38
|
Hi, When I use matplotlib for a scatter plot with both dots and connecting lines, the exported eps file is huge, if the distances between many points are small. I think of this as a bug, since no preview tiff is included in the generated eps and a variety of text processing applications (including OpenOffice) crash when I try to import the eps. Ghostscript takes forever, too. Is there anything that I can do in order to export reasonable eps files? I am using: python 2.4.2 matplotlib 0.87.2 numpy 0.9.8 with Linux The following small example illustrates the problem: -- import pylab,numpy,random random.seed() x=[random.gauss(0,1)/float(i)**2 for i in xrange(1,1000000)] X=numpy.array(x,numpy.Float32) pylab.plot(X[1:],X[:-1],"-", c="#eeeeee") pylab.plot(X[1:],X[:-1],"xk") pylab.show() -- The resulting eps file: -rw-r----- 1 xx users 212190257 Jul 4 09:39 image.eps Thanks a lot in advance Martin |
|
From: Darren D. <dd...@co...> - 2006-07-07 19:13:28
|
Hi Martin, I suggest upgrading to 0.87.3. I can run your test script and can open the resulting eps file. Please note, however, that you are asking for a file that plots 2e6 points. We have already optimized the postscript commands such that each marker or line requires essentially only a single line of postscript code (a great improvement over mpl version 0.87.2), but that still means that we need to write 2e6 points x 18 bytes per point ~ 36 MB (it actually ends up being 41MB), and postscript then has to interpret that massive file. This yields about a factor of 5 improvement in the size of your file, and its about the best we can do for postscript. If you want a smaller file size, I suggest you convert your file to some other format, since most of your data points lie on top of one another, and then convert back to eps if you really need that format. For example, you can convert your 41MB eps file into a 274KB pdf file or a 6KB png file. Finally, we dont include tiff previews in our eps files, so this is not a bug. Darren On Friday 07 July 2006 12:21, Martin Manns wrote: > Hi, > > When I use matplotlib for a scatter plot with both dots and connecting > lines, the exported eps file is huge, if the distances between many points > are small. I think of this as a bug, since no preview tiff is included in > the generated eps and a variety of text processing applications (including > OpenOffice) crash when I try to import the eps. Ghostscript takes forever, > too. Is there anything that I can do in order to export reasonable eps > files? > > I am using: > python 2.4.2 > matplotlib 0.87.2 > numpy 0.9.8 > > with Linux > > The following small example illustrates the problem: > -- > import pylab,numpy,random > random.seed() > x=[random.gauss(0,1)/float(i)**2 for i in xrange(1,1000000)] > X=numpy.array(x,numpy.Float32) > pylab.plot(X[1:],X[:-1],"-", c="#eeeeee") > pylab.plot(X[1:],X[:-1],"xk") > pylab.show() > -- > > The resulting eps file: > -rw-r----- 1 xx users 212190257 Jul 4 09:39 image.eps > > Thanks a lot in advance > > Martin > > > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job > easier Download IBM WebSphere Application Server v.1.0.1 based on Apache > Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Darren S. Dale, Ph.D. Cornell High Energy Synchrotron Source Cornell University 200L Wilson Lab Rt. 366 & Pine Tree Road Ithaca, NY 14853 dd...@co... office: (607) 255-9894 fax: (607) 255-9001 |
|
From: Eric F. <ef...@ha...> - 2006-07-07 19:30:51
|
Martin, When I try your example with svn matplotlib, I get a 34 MB eps file, and looking at it, I don't see much room for making it smaller--there is one obvious optimization, abbreviating "marker", but that's it. (The svg file is 456 MB!) So, maybe some major optimization has already been done between mpl 0.87.2 and svn. The bigger problem is that each file format has basic characteristics and limitations. If you draw a million markers and line segments, you are inevitably going to have a big postscript file, unless the postscript backend somehow detects the fact that almost all of your points are indistinguishable and therefore deletes most of them--and this is really asking too much of a plotting backend, I think. (An alternative is to generate a pixel image and make the postscript from that; this is what matlab does under some circumstances, but it can result in big files of poor quality.) Your options include: filter your points beforehand so you only plot points that are distinct; or use a pixel-based format like png, which keeps the file size under control. Eric Martin Manns wrote: > Hi, > > When I use matplotlib for a scatter plot with both dots and connecting lines, > the exported eps file is huge, if the distances between many points are small. > I think of this as a bug, since no preview tiff is included in the generated eps > and a variety of text processing applications (including OpenOffice) crash > when I try to import the eps. Ghostscript takes forever, too. Is there anything > that I can do in order to export reasonable eps files? > > I am using: > python 2.4.2 > matplotlib 0.87.2 > numpy 0.9.8 > > with Linux > > The following small example illustrates the problem: > -- > import pylab,numpy,random > random.seed() > x=[random.gauss(0,1)/float(i)**2 for i in xrange(1,1000000)] > X=numpy.array(x,numpy.Float32) > pylab.plot(X[1:],X[:-1],"-", c="#eeeeee") > pylab.plot(X[1:],X[:-1],"xk") > pylab.show() > -- > > The resulting eps file: > -rw-r----- 1 xx users 212190257 Jul 4 09:39 image.eps > > Thanks a lot in advance > > Martin > > > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
|
From: John H. <jdh...@ac...> - 2006-07-07 19:42:05
|
>>>>> "Eric" == Eric Firing <ef...@ha...> writes:
Eric> Martin, When I try your example with svn matplotlib, I get a
Eric> 34 MB eps file, and looking at it, I don't see much room for
Eric> making it smaller--there is one obvious optimization,
Eric> abbreviating "marker", but that's it. (The svg file is 456
Eric> MB!) So, maybe some major optimization has already been
Eric> done between mpl 0.87.2 and svn.
Yep, Darren got "draw_markers" properly implemented for backend PS.
This function is much better in time and space; I believe only *Agg
and PS implement it, but it could be ported over to SVG fairly easily
by modifying the PS implementation.
Eric> The bigger problem is that each file format has basic
Eric> characteristics and limitations. If you draw a million
Eric> markers and line segments, you are inevitably going to have
Eric> a big postscript file, unless the postscript backend somehow
Eric> detects the fact that almost all of your points are
Eric> indistinguishable and therefore deletes most of them--and
Eric> this is really asking too much of a plotting backend, I
Agg does this for draw_lines -- it drops points in the path that are
less one pixel away from the previous point.
JDH
|
|
From: Darren D. <dd...@co...> - 2006-07-08 18:43:11
|
On Friday 07 July 2006 3:30 pm, Eric Firing wrote: > Martin, > > When I try your example with svn matplotlib, I get a 34 MB eps file, and > looking at it, I don't see much room for making it smaller--there is one > obvious optimization, abbreviating "marker", but that's it. Thanks for the suggestion. the abbreviation is "o" as of svn 2548. |
|
From: Christopher B. <Chr...@no...> - 2006-07-10 19:02:07
|
John Hunter wrote:
>>>>>> "Christopher" == Christopher Barker <Chr...@no...> writes:
> Christopher> Just as a note, if you have Cairo, you have PS, PDF,
> Christopher> SVG, raster, and, indeed, native draw-to-the-screen
> Christopher> functionality.
>
> Last I checked if I recall correctly, about a year ago, the PS backend
> merely dumped a raster image and didn't do real vector graphics. Has
> this changed?
There has been a LOT of work on Cairo in the last year, including the PS
back-end. I'm just a lurker at this point, so I don't know how robust it
is, but it supports vector operations for at least the common stuff.
Here's part of a note posted in April to the mailing list:
"""
Is the output using image fallbacks in a case where you think it
shouldn't, (that is, your drawing doesn't have any fancy
translucence or something else that PostScript can't support
natively). In particular, I want to know if cairo is now using
fallbacks for something that was handled natively by the cairo 1.0
series.
"""
Which implies to me that it's working, and getting better.
My main thought about Cairo is that there is little point in duplicating
the effort that the Cairo devs are doing, even if it doesn't support a
feature or two that is needed. It's better to contribute to Cairo.
That is, unless, you are allergic to C (which I am mildly) or you have
good reason to think that the whole framework of Cairo is inadequate.
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chr...@no...
|