From: Axel F. <fre...@us...> - 2008-05-18 11:42:54
|
Hello, I tried to find a solution now - and I have one: In fact it's really easy: just plot two graphs. For the first one, the text-color and the color of the axes is set to white. This graph is then converted to a jpeg by pipeGS. The second graph gets the axes-sizes (min and max values for each axes, total size of the Graph) from the first graph. Nothing is plotted in this graph, just the jpg-File from the first graph is included. With that, the axes and the text are plotted as vectors, and the surface is plotted as a jpeg. The same should also work for all types of 2d-graphs. For the example "surface.py", the following code works: from pyx import * col = color.gray.white whitetext=text.texrunner() whitetext.set(mode="latex") whitetext.preamble(r"\usepackage{color}") whitetext.preamble(r"\definecolor{COL}{gray}{1}") axis_texter = graph.axis.texter.decimal(prefix=r"\textcolor{COL}{",suffix=r"}") paint=graph.axis.painter.regular( texrunner = whitetext, basepathattrs = [color.gray.white], tickattrs = [color.gray.white] ) g1 = graph.graphxyz(size=4, x2=None, y2=None, x = graph.axis.linear(painter=paint,texter = axis_texter), y = graph.axis.linear(painter=paint,texter = axis_texter), z = graph.axis.linear(painter=paint,texter = axis_texter), ) g1.plot(graph.data.file("surface.dat", x=1, y=2, z=3), [graph.style.surface()]) g1.pipeGS("surface_tmp.jpg") c = canvas.canvas() g2 = graph.graphxyz(size=4, x2=None, y2=None, x = graph.axis.linear( min = g1.axes["x"].data.min, max = g1.axes["x"].data.max), y = graph.axis.linear( min = g1.axes["y"].data.min, max = g1.axes["y"].data.max), z = graph.axis.linear( min = g1.axes["z"].data.min, max = g1.axes["z"].data.max), ) g2.insert(bitmap.bitmap(g1.bbox().left(), g1.bbox().bottom(), bitmap.jpegimage("surface_tmp.jpg"), height=g1.bbox().height(), compressmode=None)) g2.writeEPSfile("surface") g2.writePDFfile("surface") HTH, Axel On Fri, May 16, 2008 at 10:12:31AM +0200, Axel Freyn wrote: > Hi all, > > may be one possibility would be to write a subroutine which separates text > and images, and then convert the image-part using pipeGS, and add the > text-part on top of it? > I'm thinking of a code like > text_items=[] > graph_items=[] > for item in canvas.items: > if item.__class__.__name__ == "textbox": > text_items.append(item) > else: > if item.__class__.__name__ == "graphxy": > item.dolayout() > # loop over all sub-elements of this graphxy and remove all texts > ... > else: > graph_items.append(item) > graph_canvas = canvas.canvas() > graph_canvas.items = graph_items > text_canvas = canvas.canvas() > text_canvas = text_items > > graph_canvas.insert(text_canvas) > > Well, there mightl be some problems to code, as you have to loop recursively > over all elements (if you include a canvas into another canvas), and you > have to think about the internals of e.g. graphxy (I don't know how to > remove there all text - may be changing recursively all texter's of the > objects? And how to calculate this text and add it to the other list?), or > what to do with transformations,... > > What do you think about it? May be it could be nice to have such a > subroutine integrated in regular PyX - especially for 3D-Plots, or am I > missing something? > > Axel > > On Fri, May 16, 2008 at 8:50 AM, Benedikt Koenig <li...@be...> wrote: > > > Hi André, > > > > like Jörg already pointed out I am indeed looking for a way to convert > > only the 3d surface to bitmap and keep the scalable fonts and axes. I > > think such a mix of bitmap and vector parts should be possible in PDF. > > As I mentioned, I am aware of the pipeGS method but it's not exactly > > what I mean. > > > > Thanks anyway, > > benedikt > > > > Am Donnerstag, den 15.05.2008, 10:00 +0200 schrieb André Wobst: > > > Hi Benedikt, > > > > > > I've used bitmap converted figures before as well. In recent PyX > > > versions you can quite easily create such bitmaps by the pipeGS method > > > of a canvas. Note that jpg and png files created this way can be used > > > in pdfLaTeX directly. > > > > > > HTH, > > > > > > > > > André > > > > > > > > > Am 08.05.2008 um 10:35 schrieb Benedikt Koenig: > > > > > > > Hi All, > > > > > > > > I have a problem concerning the file size of my plots. Producing 3d > > > > graphs of my data leads to single PDF files of several MB size. > > > > Including these graphs in my paper gives a nice to print document, but > > > > it is way to big for easy electronic distribution as PDF. So I was > > > > thinking if there is a way to produce these high quality vector > > > > graphics > > > > for the print version of the paper but to somehow get some smaller > > > > sized > > > > graph files for the electronic version. > > > > > > > > Currently I am limiting the size by plotting only every x-th point. > > > > But > > > > obviously this is a stupid solution if you are lucky enough to have > > > > high > > > > resolution data in the first place. Alternatively I could use pipeGS > > > > to > > > > produce bitmaps of the complete graph, but I'd rather keep the axes > > > > and > > > > text as vectors and only have the actual data as bitmap. > > > > > > > > My idea is basically to produce the highly resolved 3d graph, then > > > > convert the plotted data into a bitmap while keeping axes and text in > > > > vector format and then write the whole stuff to a PDF. This should > > > > keep > > > > file sizes moderate even if the bitmap has printing quality of around > > > > 300 dpi. > > > > > > > > Are there any opinions on whether some thing like this is possible at > > > > all using PyX and if yes, how to do it? Or is there any other way to > > > > keep file size small for complexe plots? > > > > > > > > Thanks already, > > > > bene > > > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------------------------- > > > > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference > > > > Don't miss this year's exciting event. There's still time to save > > > > $100. > > > > Use priority code J8TL2D2. > > > > > > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone > > > > _______________________________________________ > > > > PyX-user mailing list > > > > PyX...@li... > > > > https://lists.sourceforge.net/lists/listinfo/pyx-user > > > > > > > > > > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by: Microsoft > > Defy all challenges. Microsoft(R) Visual Studio 2008. > > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > > _______________________________________________ > > PyX-user mailing list > > PyX...@li... > > https://lists.sourceforge.net/lists/listinfo/pyx-user > > |