JuliaInterop / NBInclude.jl

import code from IJulia Jupyter notebooks into Julia programs
Other
117 stars 17 forks source link

Is there a way to make PyPlots not show up? #20

Closed mauro3 closed 2 years ago

mauro3 commented 3 years ago

I've encountered it a few times now that I wanted to include a notebook which produces plots (with PyPlot), but the include is not for the plots it produces but for the functions it contains. Is there a way to suppress the plot output in the included location without having to comment them out in the source notebook?

stevengj commented 3 years ago

You can use the regex keyword for this — it lets you either add a comment tag to the cells that you want to include, for example.

It might be useful to support a complementary regex for cells that you want to exclude, since negative regexes are a pain to construct.

stevengj commented 3 years ago

You could also do

using PyPlot
PyPlot.isjulia_display[] = false
plt."switch_backend"("Agg")
plt."ioff"()

maybe, to prevent PyPlot from displaying anything.

knuesel commented 3 years ago

Here's an example to filter-out cells that contain # nbinclude:ignore:

@nbinclude("a.ipynb"; regex=r"^(?!.*#\s*nbinclude:ignore\b)")