Display SVG in Jupyter notebook


#1

I forgot how to do this. I have an SVG image in

/tmp/t.svg

and I want to display it in a Jupyter notebook. But as a graphic, not like this:

I tried the obvious

display(load("/tmp/t.svg"))

but no luck:

FileIO.File{FileIO.DataFormat{:UNKNOWN}}("/tmp/t.svg") couldn't be recognized by FileIO.

although that does work for PNG images (after loading FileIO).

I’m working on Julia v0.6.


#2

One answer is:

open("/tmp/test.svg") do f
   display("image/svg+xml", readstring(f))
end

Kind of obvious now! :slight_smile: