using IJuliaPortrayals
This is a demo of the IJuliaPortrayals package.
Frequencies is one of my favorite movies. And, the director was engaging on twitter, which was cool. So, a shoutout to OXV: The Manual.
Vimeo("131076011")
One of my favorite coder talks:
YouTube("_ahvzDzKdB0")
I really miss GeoCities.
GIF("hamsters.gif")
Oh, Lena. You will be forever etched into the optic nerves of anyone who has ever done image processing.
JPEG("lena.jpg")
CSS("body{padding:20px}")
HTML
is part of IJulia
proper for the 0.4.x
branch. I preferentially use that where possible.
HTML("""
<div style="background-color:aliceblue;border:1px solid navy;color:navy;font-weight:bold;padding:3px;">
Look, my own .info bar!
</div>
""")
run(`cat my.html`)
<table> <tr> <th>Features</th> <th>Something</th> </tr> </table>
IncludeHTML
includes a local file.
IncludeHTML("my.html")
Features | Something |
---|
Bring back 2003-era pages with IFrame
!
IFrame(600, 200, "http://julialang.org")
PNG("/Users/generativist/Downloads/julialang.png")
You can write an SVG
document inline, just like HTML
. Or, you can include it FromFile
.
SVG("""
<svg width="100" height="100">
<circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" />
</svg>
""")
SVG(FromFile("ball.svg"))
JavaScript is useful if you're iteratively making nice D3.js visualizations. Here, I just change some text.
HTML("""<div id="myel">No Text.</div>""")
JavaScript("""\$('#myel').text("Hello, World")""")
The $
-interpolation is annoying sometimes. So, there is a JavaScript format string specifier.
JavaScript(JS"$('#myel').text('Hello, World -- again.')")
Finally, there is music. By default it is not embedded due to size considerations. But, for small clips it's fine. (Protip: Add a mp3 to the end of your long-running script, then run all the cells.)
MP3("llama.mp3", true #= embedded =#)
WAV("mario.wav", true #= embedded =#)
OGG("starcraft.ogg", true #= embedded =#)
Keno wrote a GraphViz binding for Julia. I don't use it as a portrayal. Instead, I just do a system call via backtick command invocation. This is lightweight, and it doesn't add another requirement if you don't want GraphViz. But, GraphViz portrayals in notebooks tend to be very useful for sketching ideas. So, I've included it.
The constructor looks like:
GraphViz(dot::String; engine="dot", image_type="svg")```
The valid engines are: `circo`, `dot`, `fdp`, `neato`, `sfdp`, and `twopi`.
Currently, valid image formats are only `svg` and `png`. But, in a notebook, it is rare you would want anything but `svg`.
GraphViz("""digraph {
"Profit?" [color=green];
edge [color=gray];
"Learn Julia" -> "Write Packages";
"Learn Julia" -> "Tweet About Julia";
"Learn Julia" -> "Write Simulations";
"Write Packages" -> "Profit?";
"Tweet About Julia" -> "Profit?";
"Write Simulations" -> "Profit?";
}""")
GraphViz("""digraph {
"Profit?" [color=green];
edge [color=gray];
"Learn Julia" -> "Write Packages";
"Learn Julia" -> "Tweet About Julia";
"Learn Julia" -> "Write Simulations";
"Write Packages" -> "Profit?";
"Tweet About Julia" -> "Profit?";
"Write Simulations" -> "Profit?";
}""", image_type="png")