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

**URL:** <https://discourse.julialang.org/t/fastest-time-to-plot-for-jupyter-demos-tutorials-after-precompilation-but-from-otherwise-cold-start/8114>\
**Category:** New to Julia\
**Tags:** plotting, tutorials\
**Created:** [January 2, 2018, 6:18pm UTC](https://discourse.julialang.org/t/fastest-time-to-plot-for-jupyter-demos-tutorials-after-precompilation-but-from-otherwise-cold-start/8114 "2018-01-02T18:18:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jlperla](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlperla/32/34332_2.png) [@jlperla](https://discourse.julialang.org/u/jlperla)\
**Post date:** [January 2, 2018, 6:18pm UTC](https://discourse.julialang.org/t/fastest-time-to-plot-for-jupyter-demos-tutorials-after-precompilation-but-from-otherwise-cold-start/8114/1 "2018-01-02T18:18:51Z")

</div>

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

```julia
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.

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

```

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [January 2, 2018, 6:29pm UTC](https://discourse.julialang.org/t/fastest-time-to-plot-for-jupyter-demos-tutorials-after-precompilation-but-from-otherwise-cold-start/8114/2 "2018-01-02T18:29:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jlperla](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlperla/32/34332_2.png) [@jlperla](https://discourse.julialang.org/u/jlperla)\
**Post date:** [January 2, 2018, 6:52pm UTC](https://discourse.julialang.org/t/fastest-time-to-plot-for-jupyter-demos-tutorials-after-precompilation-but-from-otherwise-cold-start/8114/3 "2018-01-02T18:52:28Z")

</div>

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

```julia
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](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)

```julia
using Plots
gr()
plot(sin)

```

---

<div class="post-metadata">

**Author:** ![MA\_Laforge](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ma_laforge/32/385_2.png) [@MA\_Laforge](https://discourse.julialang.org/u/MA_Laforge)\
**Post date:** [January 3, 2018, 4:50pm UTC](https://discourse.julialang.org/t/fastest-time-to-plot-for-jupyter-demos-tutorials-after-precompilation-but-from-otherwise-cold-start/8114/4 "2018-01-03T16:50:06Z")

</div>

…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](https://discourse.julialang.org/t/ann-new-interactive-plots-jl-backend-for-large-datasets/1442)).

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: [GitHub - ma-laforge/InspectDR.jl: Fast, interactive Julia/GTK+ plots (+Smith charts +Gtk widget +Cairo-only images)](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](https://github.com/ma-laforge/InspectDR.jl/tree/master/sample)

### Sample output:

- [FileRepo/InspectDR/sampleplots/README.md at master · ma-laforge/FileRepo · GitHub](https://github.com/ma-laforge/FileRepo/blob/master/InspectDR/sampleplots/README.md)
- [FileRepo/SignalProcessing/sampleplots/README.md at master · ma-laforge/FileRepo · GitHub](https://github.com/ma-laforge/FileRepo/blob/master/SignalProcessing/sampleplots/README.md)

### Warning:

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

### Sample minimal Code:

```julia-auto
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:

```julia-auto
#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

```

---

<div class="post-metadata">

**Author:** ![jlperla](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlperla/32/34332_2.png) [@jlperla](https://discourse.julialang.org/u/jlperla)\
**Post date:** [January 3, 2018, 5:13pm UTC](https://discourse.julialang.org/t/fastest-time-to-plot-for-jupyter-demos-tutorials-after-precompilation-but-from-otherwise-cold-start/8114/5 "2018-01-03T17:13:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![amellnik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amellnik/32/137_2.png) [@amellnik](https://discourse.julialang.org/u/amellnik)\
**Post date:** [January 3, 2018, 8:57pm UTC](https://discourse.julialang.org/t/fastest-time-to-plot-for-jupyter-demos-tutorials-after-precompilation-but-from-otherwise-cold-start/8114/6 "2018-01-03T20:57:00Z")

</div>

```julia
@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.

---

<div class="post-metadata">

**Author:** ![jlperla](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlperla/32/34332_2.png) [@jlperla](https://discourse.julialang.org/u/jlperla)\
**Post date:** [January 3, 2018, 9:34pm UTC](https://discourse.julialang.org/t/fastest-time-to-plot-for-jupyter-demos-tutorials-after-precompilation-but-from-otherwise-cold-start/8114/7 "2018-01-03T21:34:21Z")

</div>

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.
