diff --git a/README.md b/README.md index 1758146..2256646 100644 --- a/README.md +++ b/README.md @@ -58,14 +58,14 @@ end ```` ### Movies -Currently, these can be recorded with Makie and Plots backends both from -the REPL and Pluto notenooks. MP4 files and gifs can be created. +Currently, these can be recorded with GLMakie, CairoMakie and Plots backends both from +the REPL and Pluto notebooks. MP4 files and gifs can be created. PyPlot possibly will follow. This shows the animated graphic in the REPL (essentially the same as above) -and creates an embedded video in a Pluto notebook. +and creates an embedded video in a Pluto notebook: ```` -vis=GridVisualizer(Plotter=GLMakie) +vis=GridVisualizer(Plotter=Plots) movie(vis) do vis for i=1:N function=calculate(i) @@ -75,7 +75,7 @@ movie(vis) do vis end ```` -To save to a file, use +To save to a file instead of showing in a notebooks or from the REPL , use: ```` vis=GridVisualizer(Plotter=CairoMakie) movie(vis, file="video.mp4") do vis @@ -120,8 +120,9 @@ and all plotting functions will do nothing. - 'i': some level of interactive control - '(y)': availability only on rectangular grids - 'p': planned +- 'n': probably not, also in the future -| | PyPlot | GLMakie | PlutoVista | Plots | VTKView | +| | PyPlot | Makie | PlutoVista | Plots | VTKView | |----------------|--------|---------|------------|-------|---------| | scalarplot, 1D | y | y | y,i | y | y | | vectorplot, 1D | y | y | y | y | y | @@ -130,10 +131,11 @@ and all plotting functions will do nothing. | vectorplot, 2D | y | y | y | y | | | streamplot, 2D | y | p | p | | | | gridplot, 2D | y | y,i | y | (y) | y,i | -| scalarplot, 3D | y | y,i | y,i | | y,i | -| gridplot, 3D | y | y,i | y,i | | y,i | -| vectorplot, 3D | p | p | p | | | -| streamplot, 3D | | p | p | | | +| scalarplot, 3D | y | y,i | y,i | n | y,i | +| gridplot, 3D | y | y,i | y,i | n | y,i | +| vectorplot, 3D | p | p | p | n | | +| streamplot, 3D | | p | p | n | | +| movie | p | y | n | y | | diff --git a/docs/makeplots.jl b/docs/makeplots.jl index 1f4db62..2cda5fe 100644 --- a/docs/makeplots.jl +++ b/docs/makeplots.jl @@ -59,5 +59,9 @@ function makeplots(picdir; Plotter=GLMakie, extension="png") println("grid1d") + fname=joinpath(picdir,"plotting_video."*"gif") + p=plotting_movie(;filename=fname,Plotter=Plotter) + @test isfile(fname) + println("plotting_video") true end diff --git a/examples/plotting.jl b/examples/plotting.jl index 5be764d..e8ee6cf 100644 --- a/examples/plotting.jl +++ b/examples/plotting.jl @@ -128,6 +128,25 @@ function plotting_stream2d(; Plotter = default_plotter(), kwargs...) end # ![](plotting_stream2d.svg) +# ### Movie +# Movies can contain any of the previous plots. +function plotting_movie(;filename="plotting_video.gif", Plotter=default_plotter()) + vis=GridVisualizer(Plotter=Plotter,size=(600,200),layout=(1,2)) + X=0:0.2:10 + grid=simplexgrid(X,X) + movie(vis,file=filename) do vis + for t=0:0.1:10 + f=map( (x,y)-> sin(x-t)*cos(y-t),grid) + g=map( (x,y)-> sin(t)*sin(x)*cos(y),grid) + scalarplot!(vis[1,1],grid,f,clear=true, title="t=$(t)",limits=(-1,1),levels=7,colormap=:hot) + scalarplot!(vis[1,2],grid,g,clear=true, title="t=$(t)",limits=(-1,1),levels=7,colormap=:hot) + reveal(vis) + end + end +end +# ![](plotting_video.gif) + + # ## Multiscene plots # We can combine multiple plots into one scene according to # some layout grid given by the layout parameter. diff --git a/examples/plutovista.jl b/examples/plutovista.jl index 3b0fc99..25c5e5b 100644 --- a/examples/plutovista.jl +++ b/examples/plutovista.jl @@ -1,5 +1,5 @@ ### A Pluto.jl notebook ### -# v0.19.16 +# v0.19.22 using Markdown using InteractiveUtils @@ -7,12 +7,7 @@ using InteractiveUtils # This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error). macro bind(def, element) quote - local iv = try - Base.loaded_modules[Base.PkgId(Base.UUID("6e696c72-6542-2067-7265-42206c756150"), - "AbstractPlutoDingetjes")].Bonds.initial_value - catch - b -> missing - end + local iv = try Base.loaded_modules[Base.PkgId(Base.UUID("6e696c72-6542-2067-7265-42206c756150"), "AbstractPlutoDingetjes")].Bonds.initial_value catch; b -> missing; end local el = $(esc(element)) global $(esc(def)) = Core.applicable(Base.get, el) ? Base.get(el) : iv(el) el @@ -116,7 +111,7 @@ t4: $(@bind t4 PlutoUI.Slider(-10:0.1:10, default=0, show_value=true)) # ╔═╡ c1278fb2-3e75-445f-893a-b8b8a7e931d3 p = GridVisualizer(; resolution = (600, 200), dim = 1, legend = :lt); -p; + # ╔═╡ 661531f7-f740-4dd4-9a59-89ddff06ba5c scalarplot!(p, X2, f2(t4); show = true, clear = true, color = :red, label = "t=$(t4)") @@ -170,7 +165,6 @@ end # ╔═╡ faa59bbd-df1f-4c62-9a77-c4752c6a6df4 vis = GridVisualizer(; resolution = (300, 300), dim = 2); -vis; # ╔═╡ 6f1707ed-79ab-42dc-8ad8-d66a9e1a65b3 md""" @@ -235,8 +229,10 @@ scalarplot!(p3d, g3, f3; levels = [flevel], xplanes = [xplane], yplanes = [yplan levelalpha = 0.5) # ╔═╡ d924d90d-4102-4ae8-b8de-254a17a5d4df -X4 = -1:0.1:1; -g4 = simplexgrid(X4, X4, X4); +begin + X4 = -1:0.1:1; + g4 = simplexgrid(X4, X4, X4); +end # ╔═╡ 57ed5eea-bc1c-45eb-b4d3-dc63088db21a scalarplot(g4, map((x, y, z) -> 0.01 * exp(-10 * (x^2 + y^2 + z^2)), g4); levels = 10) @@ -348,8 +344,10 @@ md""" """ # ╔═╡ 6a3b2356-e8a1-45f8-8648-2eca09a7b258 -XX = 0:0.1:1; -YY = 0:0.1:10; +begin + XX = 0:0.1:1; + YY = 0:0.1:10; +end # ╔═╡ 608a5704-a84c-4c55-8642-ecddb275dc1b scalarplot(XX, YY, (x, y) -> sin(4x) * 10 * y; aspect = 0.1, xlabel = "aaa",