Makie overloads the
FileIO interface, so it is simple to save plots as images or videos.
To save a
scene as an image, you can just write e.g.:
Makie.save("plot.png", scene) Makie.save("plot.jpg", scene)
scene is the scene handle.
In the backend,
ImageMagick is used for the image format conversions.
Stepper is a scene type that simplifies the cumulative plotting, modifying of an existing scene, and saving of scenes. These are great for showing off progressive changes in plots, such as demonstrating the effects of theming or changing data.
You can initialize a
Stepper by doing:
st = Stepper(scene, @replace_with_a_path)
and save the scene content & increment the stepper by using:
using Makie function stepper_demo() scene = Scene() pos = (50, 50) steps = ["Step 1", "Step 2", "Step 3"] colors = AbstractPlotting.to_colormap(:Set1, length(steps)) lines!(scene, Rect(0,0,500,500), linewidth = 0.0001) # initialize the stepper and give it an output destination st = Stepper(scene, "C:\\Users\\sdani\\.julia\\dev\\Makie\\docs\\media\\stepper_demo") for i = 1:length(steps) text!( scene, steps[i], position = pos, align = (:left, :bottom), textsize = 100, font = "Blackchancery", color = colors[i], scale_plot = false ) pos = pos .+ 100 step!(st) # saves the step and increments the step by one end st end stepper_demo()
It is also possible to output animated plots as videos (note that this requires
ffmpeg to be installed and properly configured on your computer (test this by running
ffmpeg -version from a terminal window).)
record(func, scene, path)
record(scene, "test.gif") do io for i = 1:100 scene.plots[:color] = ...# animate scene recordframe!(io) # record a new frame end end
record(func, scene, path, iter)
record(scene, "test.gif", 1:100) do i scene.plots[:color] = ...# animate scene end
For recording of videos (either as .mp4 or .gif), you can do:
record(scene, "video.mp4", itr) do i func(i) # or some other animation in scene end
itr is an iterator and
scene is the scene handle.
It is also possible to
record to gifs:
record(scene, "video.gif", itr) do i func(i) # or some other animation in scene end
In both cases, the returned value is a path pointing to the location of the recorded file.
using Makie scene = Scene() f(t, v, s) = (sin(v + t) * s, cos(v + t) * s, (cos(v + t) + sin(v)) * s) t = Node(Base.time()) # create a life signal limits = FRect3D(Vec3f0(-1.5, -1.5, -3), Vec3f0(3, 3, 6)) p1 = meshscatter!(scene, lift(t-> f.(t, range(0, stop = 2pi, length = 50), 1), t), markersize = 0.05)[end] p2 = meshscatter!(scene, lift(t-> f.(t * 2.0, range(0, stop = 2pi, length = 50), 1.5), t), markersize = 0.05)[end] lines = lift(p1, p2) do pos1, pos2 map((a, b)-> (a, b), pos1, pos2) end linesegments!(scene, lines, linestyle = :dot, limits = limits) # record a video N = 150 record(scene, "C:\\Users\\sdani\\.julia\\dev\\Makie\\docs\\media\\record_video.mp4", 1:N) do i push!(t, Base.time()) end
For more info, consult the Examples index.