In some cases, there appears to be a bug in SVG image handling. For
example, the image in the colorbar is not properly sized
import pylab as p
p.imshow(p.rand(5,3))
p.colorbar()
p.savefig('test.svg')g
p.show()
This problem appeared before and after Steve's application of
Norbert's PNG patch (thanks's Norbert!) so it looks like something
else is to blame. See also contourf_demo, in which SVG appears broken
in a perhaps unrelated way.
On the subject, Steve asked offlist whether Agg could write to a file
object rather than disc, which obviate the need to create a temporary
PNG which is subsequently embedded in the SVG file.
I tried this several months ago. The relevant code is src/_image.cpp
Image::write_png where we do
std::string fileName = Py::String(args[0]);
const char *file_name = fileName.c_str();
FILE *fp;
png_structp png_ptr;
fp = fopen(file_name, "wb");
...snip...
png_init_io(png_ptr, fp);
At one point I tried to figure out how to make this work with
StringIO, but was stumped because PNG appears to require a file
pointer and StringIO doesn't emulate this at extension code level, as
far as I can see. Anyone know otherwise? Maybe a question for
python-list....
JDH