Fastest time-to-plot for Jupyter demos/tutorials (after precompilation, but from otherwise cold start)?

I am setting up some Jupyter notebooks to go over in my classes, and give students files to start working with.

My constraints are:

  1. I will do a precompilation step offline, and tell users they will do the same (and to not get irritated in the middle).
  2. Relatively simple plotting requirements, but don’t want bleeding edge.
  3. Focus on Jupyter in new notebooks, but need to at least work in Juno
  4. I will tell people to use this as the “quick and dirty” solution, and that they can use Plots.jl or something fancier for real work.
  5. My main criteria is: start up a notebook, type in the text, and how long does it take?

Main Question: What is the best quick-and-dirty library for Jupyter tutorials? As a more general point for Julia in the short-term, there is no reason we need to use the same plots library for “real work” and for tutorials. Pick something stable and fast for all of the tutorials, and tell people other libraries are useful for production work (i.e. see where Plots.jl and others go).


As an example, after the precompilation for PlotlyJS, I booted up a new notebook on JuliaBox and used

import PlotlyJS
x = linspace(0, 10, 200)
y = sin.(x)
# specify which module scatter belongs to since both have scatter
PlotlyJS.plot(PlotlyJS.scatter(x=x, y=y, marker_color="blue", line_width=2))

and it took 18-20 seconds before the plot showed. With pyplot (after precompilation) a new notebook took about 16 seconds before this plot showed.

using PyPlot
x = linspace(0, 10, 200)
y = sin.(x)
plot(x, y, "b-", linewidth=2)

It is not the prettiest, but I found gr() to be reasonably fast.

@
@Tamas_Papp Thanks!
It is fast. The following took onto 8 seconds to display in a new notebook:

using GR
plot(1:.01:10, sin.(1:.01:10))

The main issue I have with gr is that I can’t seem to find good documentation that does not use the Plots backend? Am I missing something obvious? https://github.com/jheinen/GR.jl seems to really push it as the backend.


With Plots, of course, the following took 38 seconds to display in a new notebook (after precompilation)

using Plots
gr()
plot(sin)

…If you don’t need fancy advanced features like 3D plots & pie charts, but still want publication-quality 2D plots:

You could also use InspectDR (ANN: New interactive Plots.jl backend for large datasets).

InspectDR has the advantage over GR by providing basic interactivity:

  • Mouse/keyboard bindings for pan/zoom
  • Programmatic + user-level control of annotations (ex: delta markers).

…Hopefully GR will start providing some interactivity features soon as well (it is supposedly on the TODO list).

The usage documentation for InspectDR is on the Github home page: https://github.com/ma-laforge/InspectDR.jl

There is also a few sample usage cases in the “sample” subdirectory: InspectDR.jl/sample at master · ma-laforge/InspectDR.jl · GitHub

Sample output:

Warning:

Will not work in JuliaBox (JuliaBox has problems with installing the Gtk.jl package).

Sample minimal Code:

using InspectDR

x = collect(0:10) #Must vectorize using collect - ranges not yet supported
y = rand(length(x))

plot = InspectDR.Plot2D(:lin, :lin,
	title = "Sample Plot",
	xlabel = "X-Values",
	ylabels = ["Y-Values"]
)

wfrm = add(plot, x, y, id="Random Sample")

#Show Gtk GUI
gplot = display(InspectDR.GtkDisplay(), plot)

edit:
To display inline plots, use the following call to display instead:

#SVG plotting in Jupyter buggy @ the moment:
InspectDR.defaults.rendersvg = false #Call once only

display(plot) #Explicit call to "display" plot
nothing #Clear return value so we don't display plot twice

Thanks! Looks great, but alas, Jupyter and JuliaBox are essential at this point.

@time begin
    using PlotlyJS
    plot(scatter(x=[1,2,3], y=[1,2,3]), Layout())
end

takes 6.5 sec (on my desktop) and works on JuliaBox.

Edit: Whoops – I misread the original question and thought it was using Plots.jl.

2 Likes

Thanks. Yes, PlotlyJS took about 8 seconds on JuliaBox, which is plenty fast (not sure why it took 18 seconds before on JuliaBox, but perhaps it was the sin and linspace as well). I think I will tell my students to use PlotlyJS for now, and to use Plots.jl when getting fancier.