Hi, It is a very nice example. svgutils is a svg editting library and so it does not do any transformations itself. All the coordinates must be defined in the SVG space, whose origin is in the top left.
Cheers, Bartosz On 21.02.2012, at 09:33, William Hoburg wrote: > Hi > > @Jakob and Bartosz > > Thx; Both approches (PYX and svgutils) worked well. > But there are some things to consider. svgutils for instance uses coordinates > from the top left corner. > On Ubuntu (I use 11.10 x64) PYX can be installed from repository using > synaptics. svgutils can be installed without problems from the github > repository. > > I included (as text to avoid download problems for others) a example script > where I utilize mpl to generate svg and eps files and combine the eps using > PYX and the svg using svgutils. > > @ Jerzy Karczmarczuk: >> 1. You have gradients, clipping paths, patterns, and filtering, which >> interpolates between vector and raster data. You will not implement >> easily as an "artist" the blur, displacement maps, or morphologic filters > > What I intended to do can be seen in the attached svg figure. I do not need > gradient, filtering, effects and so on. I only need basic functionality like > lines or circles do add simple graphics into my mpl plot. The subfigure > inside the mpl plot was drawn in Inkscape now inserted svgutils. The > resulting svg (or eps) will be used in my lyx document which is converted to > a pdf on the fly by Inkscape. > > > @ all: Did anyone try http://cairographics.org/pyrsvg/ to achieve the above > questioned. > > Cheers, > HoWil > > > #============================================================================== > #============================================================================== > # Demo script to combine two vector graphics like eps and svg in python. > # The combined files in this demo were generated using matplotlib > > from matplotlib import * > from matplotlib.pyplot import * > > #============================================================================== > # Build a figure and export it as eps and svg in two different versions > #============================================================================== > > # Figure adjustment > f_Xsize_cm = 10.; > f_Ysize_cm = 8.; > > fig = figure(figsize=(f_Xsize_cm/2.5, f_Ysize_cm/2.5)); > > fig.patch.set_alpha(0.2) > > # > ax = fig.add_subplot(111) > ax.patch.set_alpha(0.7) > > text(0.22,0.25,'eps-SVG \n vector \n graphics',fontsize=30, > color=[0.6,0.6,0.6]) > # Fill the axis with some color > ax.set_axis_bgcolor([0.9,0.9,0.1]) > > # Remove all ticks and ticklabels to get rectangles > ax.set_yticklabels(()) > ax.set_xticklabels(()) > ax.set_xticks([]) > ax.set_yticks([]) > > # Export first version of eps and svg figure > fig.savefig('exportSub.eps'); > fig.savefig('exportSub.svg'); > > # Export second version of eps and svg figure > ax.set_axis_bgcolor([0.1,0.9,0.1]) > text(0.1,0.4,'2nd',fontsize=40, color=[0.9,0.2,0.2], rotation=45) > fig.savefig('exportSub2nd.eps'); > fig.savefig('exportSub2nd.svg'); > > > > #============================================================================== > # Utilizing 'Pyx' from http://pyx.sourceforge.net/ > #============================================================================== > from pyx import * > > c = canvas.canvas() > # load both external files > c.insert(epsfile.epsfile(0, 0, "exportSub.eps")) > c.insert(epsfile.epsfile(f_Xsize_cm/2, f_Ysize_cm/3, "exportSub2nd.eps")) > > # save generated EPS files > c.writeEPSfile("export") > > > #============================================================================== > # Utilizing 'svgutils' from https://github.com/btel/svg_utils > #============================================================================== > import svgutils.transform as sg > #import sys > > #create new SVG figure > fig = sg.SVGFigure() > > # load both external files > fig1 = sg.fromfile('exportSub.svg') > fig2 = sg.fromfile('exportSub2nd.svg') > > # get the plot objects > plot1 = fig1.getroot() > # mpl-figures have to be scaled > plot1.moveto(0, 0, scale=1.25) > > plot2 = fig2.getroot() > # x-,y- coordinates are measured from the top left corner > factor = 35.433 # scale factor cm/px, out of inkscape > plot2.moveto(f_Xsize_cm/2 * factor, -f_Ysize_cm/3 * factor, scale=1.25) > > # append plots and labels to figure > fig.append([plot1]) > fig.append([plot2]) > > # save generated SVG files > fig.save("export.svg") > > > > > -- > Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir > belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de Bartosz Telenczuk Institute for Theoretical Biology Humboldt University of Berlin, Germany Phone: +4930/2093-8838 Homepage: http://neuroscience.telenczuk.pl ------------------------------------------------------------------------------ Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users