Hello, I put a patch in the tracker that implements groups in the SVG
backend. Is that the preferred way to submit patches, or should I just
mail them?
I've also been working on images. SVG has an image tag where you can
include a external .png file. I used some code from the GTK backend to
save an image as a png, then included, as shown below.
def draw_image(self, x, y, im):
"""
Draw the Image instance into the current axes; x, y is the
upper left hand corner of the image
"""
rows, cols, s = im.as_str()
X = fromstring(s, UInt8)
X.shape = rows, cols, 4
pb=gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,
has_alpha=1, bits_per_sample=8,
width=cols, height=rows)
try: pa = pb.get_pixels_array()
except AttributeError: pa = pb.pixel_array
pa[:,:,:] = X
gc = self.new_gc()
pb.save('test.png','png')
self._draw_rawsvg('<image x=\"%f\" y=\"%f\" width=\"%f\"
height=\"%f\" xlink:href=\"test.png\"></image>' % (x, self.height-y,
cols, rows))
The above works for 'image_demo2.py' in the examples. The downside of
this approach is that it would make the SVG backend dependent on GTK.
Can anyone think of a better way?
I was thinking of naming the png files 'filename_1.png',
'filename_2.png', etc. for each image in the figure, where
'filename.svg' is the name of the main file. What do you think?
jared