Display SVG in Jupyter notebook

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.

1 Like

One answer is:

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

Kind of obvious now! :slight_smile:

2 Likes

Update for Julia 1.x:

open("/tmp/test.svg") do f
   display("image/svg+xml", read(f, String))
end
1 Like