AbstractPlotting Example Won't Work After I Change it to Makie

Hi all,

I saw this link:


I want to create the animation, but it said that “everything from AbstractPlotting is moved to Makie” thus I even modify it to this:

using Makie

v(x::Point2{T}, t) where T = Point2{T}(one(T) * x[2] * t, 4 * x[1])

sf = Node(Base.Fix2(v, 0e0))

title_str = Node("t = 0.00")

sp = Makie.streamplot(
        -2..2, -2..2;
        linewidth = 2,
        padding = (0, 0),
        arrow_size = 0.09,
        colormap =:magma

sc = title(sp, title_str)

record(sc, "output.mp4", LinRange(0, 20, 5*30)) do i
  sf[] = Base.Fix2(v, i)
  title_str[] = "t = $(round(i; sigdigits = 2))"

The errors:
LoadError: MethodError: no method matching pixelarea(::Makie.FigureAxisPlot)
Closest candidates are:

  • pixelarea(::AbstractPlotting.Scene) at ~/.julia/packages/AbstractPlotting/2A5iv/src/scenes.jl:423*
  • pixelarea(::AbstractPlotting.SceneLike) at ~/.julia/packages/AbstractPlotting/2A5iv/src/scenes.jl:424*
  • [1] title(scene::Makie.FigureAxisPlot, tstring::Observable{String}; align::Tuple{Symbol, Symbol}, textsize::Int64, parent::AbstractPlotting.Scene, formatter::Function, kw::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})*
  • @ AbstractPlotting ~/.julia/packages/AbstractPlotting/2A5iv/src/basic_recipes/title.jl:15*
  • [2] title(scene::Makie.FigureAxisPlot, tstring::Observable{String})*
  • @ AbstractPlotting ~/.julia/packages/AbstractPlotting/2A5iv/src/basic_recipes/title.jl:13*
  • [3] top-level scope*
  • @ ~/LasthrimProjection/ProjectGLMakie/plotgl.jl:18*
  • [4] include(fname::String)*
  • @ Base.MainInclude ./client.jl:451*
  • [5] top-level scope*
  • @ REPL[12]:1*
    in expression starting at /home/browni/LasthrimProjection/ProjectGLMakie/plotgl.jl:18

The example is outdated, but you yourself seem to be using an older version of Makie. Node has been deprecated in favor of Observable.

Which version are you on?

On Makie v0.19.1 this produces the desired animation

using GLMakie # or CairoMakie

v(x::Point2{T}, t) where T = Point2{T}(one(T) * x[2] * t, 4 * x[1])

sf = Observable(Base.Fix2(v, 0e0))

title_str = Observable("t = 0.00")

fig, ax, sp = Makie.streamplot(
               -2..2, -2..2;
               linewidth = 2,
               figure=(padding = (0, 0),),
               arrow_size = 0.09,
               colormap =:magma

record(fig, "output.mp4", LinRange(0, 20, 5*30)) do i
  sf[] = Base.Fix2(v, i)
  title_str[] = "t = $(round(i; sigdigits = 2))"

This is the version

   Status `~/LasthrimProjection/ProjectGLMakie/Project.toml`
  [35d6a980] ColorSchemes v3.20.0
  [e9467ef8] GLMakie v0.4.5
  [ee78f7c6] Makie v0.15.1
  [37e2e46d] LinearAlgebra

That’s a really old version. Any particular reason why you don’t use a recent one?
Makie has seen some amazing improvements since then. But also quite a few breaking changes. I’d say better learn the current system now than cling to the old.

By the way, you should have gotten an error saying title is undefined. You didn’t because AbstractPlotting was still loaded. It’s no longer required.

But actually the same code I posted above works with the older Makie.

As @skleinbo you should really upgrade your packages if possible.

And here’s a simplified version of the code (tested with Makie 0.19.1) that’s probably easier to understand:

using CairoMakie

time = Observable(0.0)

sf = @lift p -> Point2(p[2] * $time, 4 * p[1])
title = @lift string("t = ", round($time; sigdigits=2))

fig = Makie.streamplot(
        -2..2, -2..2;
        axis=(; title),

@time record(fig, "output.mp4", range(0, 20, 5*30)) do t
    time[] = t

I just add it and it is installed that version. I will use the recent one.

I have a question why would when I add Makie in another project environment it is the version 0.15.1 but in another project environment I made quite a long time ago, Makie that I added is already version 0.18.1

You give CairoMakie example and I will test it in different env.

I think Makie team should be making books of tutorial like SciPy created books for documentation with the code or like CalculusWithJulia so people can follow up the newest upgrade.

The code works:

Have you updated that environment?

Ideally an up-to-date and pedagogical documentation with many examples would exist. But that’s a lot of work to maintain. I personally find the current Makie documentation mostly sufficient. And who knows if CalculusWithJulia will be kept up to date in the long run.

1 Like

To elaborate on @skleinbo’s answer: in this old project you have an old version of GLMakie. When you install Makie there, it picks a version compatible with this old GLMakie. Try running ]update in that project.

It would be great to have a book on Makie, but it’s probably too early. Keep in mind that SciPy is a very mature project (>20 years old!). It’s very stable so people can put a lot of effort in extensive documentation and it will be valid for years to come.

On the other hand Makie is still a young project that’s evolving fast. It’s not stable (it hasn’t reached 1.0 yet). Every year there are several releases with breaking changes. If you write a book now it will be outdated in a few months.

By the way note that it took 16 years for SciPy to reach version 1.0. That happended around the same time that Makie had its first commit (end of 2017). I’m hopeful Makie will reach 1.0 before 2033 :slight_smile:


Wow, thanks a lot for the explanation. Indeed Julia is still new too born on 2012.

I just know that SciPy is that old.

You must be the master of Computer, Julia and Makie, thus can make me understand why writing Makie book is not a wise thing to do now…

Makie is great, but there are lots of plotting packages (GR, PlotlyJS, PyPlot, Gaston) in Julia, should we make vote or make competition for them all in all fields of science?