From GLMakie v0.4.7 to GLMakie v0.9.9

I am porting this code from GLMakie v0.4.7 to GLMakie v0.9.9.
This means from Makie 0.15.3 to Makie 0.21.0 (I think).

See also: Migrating from GLMakie 0.4.7 to current
I tried this already two years ago and failed, but now I must succeed.

I could not find a list of depreciations, so I have to ask item by item.

First question: How can I replace the type Node which does not longer exist?
→ answer: use Observable instead

Second error:

LoadError: UndefVarError: `Quaternionf0` not defined

→ answer: use Quaternionf instead

It’s Quaternionf.

To find all such changes, look at the file CHANGELOG.md in the Makie repository. Searching for “deprecate” or “remove” should find most of them.

1 Like

Thanks. This is what grep gave me:

  • Broadcast replaces deprecated method for quantile #2430.

  • The functions hlines!, vlines!, hspan!, vspan! and abline! were reimplemented as recipes. This allows using them without an Axis argument in first position and also as visuals in AlgebraOfGraphics.jl. Also, abline! is now called ablines! for consistency, abline! is still exported but deprecated and will be removed in the future. #2023.

  • Breaking deprecate to_colormap(cmap, ncolors) in favor of categorical_colors(cmap, ncolors) and resample_cmap(cmap, ncolors) #1901 #1723.

  • Switched to erroring instead of warning for deprecated events mousebuttons, keyboardbuttons and mousedrag.

  • Added SliderGrid block which replaces the deprecated labelslider! and labelslidergrid! functions #1796.

  • Breaking Cleaned up Scene type #1192, #1393. The Scene() constructor doesn’t create any axes or limits anymore. All keywords like raw, show_axis have been removed. A scene now always works like it did when using the deprecated raw=true. All the high level functionality like showing an axis and adding a 3d camera has been moved to LScene. See the new Scene tutorial for more info: Scene tutorial · Makie.

  • Depend on new GeometryBasics, which changes all the Vec/Point/Quaternion/RGB/RGBA - f0 aliases to just f. For example, Vec2f0 is changed to Vec2f. Old aliases are still exported, but deprecated and will be removed in the next breaking release. For more details and an upgrade script, visit GeometryBasics#97.

  • Breaking The attribute textsize has been removed everywhere in favor of the attribute fontsize which had also been in use.

  • The functions hlines!, vlines!, hspan!, vspan! and abline! were reimplemented as recipes. This allows using them without an Axis argument in first position and also as visuals in AlgebraOfGraphics.jl. Also, abline! is now called ablines! for consistency, abline! is still exported but deprecated and will be removed in the future. #2023.

  • Add linestyle and default to extrema(z) for contour, remove bitrotten fillrange #2008.

  • Added empty!(fig) and changed empty!(scene) to remove all child plots without detaching windows #1818.

  • Breaking Cleaned up Scene type #1192, #1393. The Scene() constructor doesn’t create any axes or limits anymore. All keywords like raw, show_axis have been removed. A scene now always works like it did when using the deprecated raw=true. All the high level functionality like showing an axis and adding a 3d camera has been moved to LScene. See the new Scene tutorial for more info: Scene tutorial · Makie.

  • Fixed issue where pixelcam! does not remove controls from other cameras #1504.

  • Depend on new GeometryBasics, which changes all the Vec/Point/Quaternion/RGB/RGBA - f0 aliases to just f. For example, Vec2f0 is changed to Vec2f. Old aliases are still exported, but deprecated and will be removed in the next breaking release. For more details and an upgrade script, visit GeometryBasics#97.

1 Like

that’s the one you were looking for

1 Like

Next error:

ERROR: MethodError: no method matching update_cam!(::Makie.Scene, ::Vector{Float64}, ::Vector{Float64})

I could not find update_cam! in the list of depreciated methods. How do you adjust the camera nowadays?

I think the function is still there given your error, maybe it has a different signature? Not sure, what methods does it suggest?

This is what the documentation says:

For updating eyeposition, lookat and/or upvector update_cam!(scene, eyeposition, lookat, upvector = Vec3f(0,0,1)) is preferred.

The help says:

  update_cam!(scene::Scene, eyeposition, lookat, up = Vec3f(0, 0, 1))

  Updates the camera's controls to point to the specified location.

Stacktrace:


Closest candidates are:
  update_cam!(::Makie.Scene, ::Makie.OldCamera3D, ::Any, ::Any, ::Any)
   @ Makie ~/.julia/packages/Makie/VRavR/src/camera/old_camera3d.jl:365
  update_cam!(::Makie.Scene, ::Makie.OldCamera3D, ::Any, ::Any)
   @ Makie ~/.julia/packages/Makie/VRavR/src/camera/old_camera3d.jl:365
  update_cam!(::Makie.Scene, ::Makie.AbstractCamera, ::Any)
   @ Makie ~/.julia/packages/Makie/VRavR/src/scenes.jl:542
  ...

Stacktrace:
 [1] reset_view(cam::Makie.Camera3D, scene3D::Makie.LScene)
   @ KiteViewers ~/repos/KiteViewers.jl/src/common.jl:183
 [2] Viewer3D(show_kite::Bool, autolabel::String)
   @ KiteViewers ~/repos/KiteViewers.jl/src/viewer3D2.jl:182
 [3] Viewer3D()
   @ KiteViewers ~/repos/KiteViewers.jl/src/viewer3D2.jl:125
 [4] top-level scope
   @ REPL[2]:1

But why is then this code not working any more:

update_cam!(scene3D.scene, [-15.425113, -18.925116, 5.5], [-1.5, -5.0, 5.5])

?

See also: API · Makie!
Code: KiteViewers.jl/src/common.jl at 675814210ea22e7b5fda600533053d8c8faed8b3 · aenarete/KiteViewers.jl · GitHub

The signature is function update_cam!(scene::Scene, camera::Camera3D, eyeposition::VecTypes, lookat::VecTypes, up::VecTypes = camera.upvector[]) as I see it in the source code, and VecTypes is from GeometryBasics

So the function seems only to take tuples or SVectors, not normal vectors. It was probably forgotten to document that change as internally, Makie never uses normal vectors to mean 2d or 3d points/vecs.

Vec3(-15.425113, -18.925116, 5.5) etc. should work I think

1 Like

Thank you, this works!

1 Like

My next problem are these grayish grid lines:

How can I get rid of them?

My code:

    fig = Figure(size=(840, 900), backgroundcolor=RGBf(0.7, 0.8, 1))
    scene = fig[1,1]
    scene3D = LScene(scene, scenekw=(show_axis=false, limits=Rect(-7,-10.0,0, 11,10,11), size=(800, 800)))

That’s this one

Breaking Cleaned up Scene type #1192, #1393. The Scene() constructor doesn’t create any axes or limits anymore. All keywords like raw, show_axis have been removed. A scene now always works like it did when using the deprecated raw=true. All the high level functionality like showing an axis and adding a 3d camera has been moved to LScene. See the new Scene tutorial for more info: Scene tutorial · Makie.

So I think show_axis doesn’t go under scenekw anymore.

show_axis has become a “first class” attribute:

using GLMakie
fig = Figure(size=(840, 900), backgroundcolor=RGBf(0.7, 0.8, 1))
subfigure = fig[1,1]
scene3D = LScene(subfigure, show_axis=false, scenekw=(; limits=Rect(-7, -10.0, 0, 11, 10, 11), size=(800, 800)))

Admittedly, LScene is a mess and some of the oldest code in the Makie code base, and has been only half heartedly upgraded to fit into the newer system… It’s ripe for a refactor, but nobody has had time for it so far.

1 Like

Thanks, this worked.

Next issue: I want to print text at the lower left postion of the window, a status line.

This used to work:

But it does not work any more. It uses now the origin of the 3D plot as zero position
of the text. How can I print text based on the 2D position of the GLMakie window?

The text “Stopped” should be at the bottom left of the window and not move if I turn the camera view…

hm if it used to work then scene must have been a Scene with camera = campixel!, if it’s now 3d that doesn’t really make sense, I would think your 3d scene is only the one called scene3D

I mean, you can see the old and the new definition of scene in the code:

    # scene, layout = layoutscene(resolution = (840, 900), backgroundcolor = RGBf(0.7, 0.8, 1))
    # scene3D = LScene(scene, scenekw = (show_axis=false, limits = Rect(-7,-10.0,0, 11,10,11), resolution = (800, 800)), raw=false)
    # create_coordinate_system(scene3D)
    #     cam = cameracontrols(scene3D.scene)

    fig = Figure(size=(840, 900), backgroundcolor=RGBf(0.7, 0.8, 1))
    scene = fig[1,1]
    scene3D = LScene(scene, show_axis=false, scenekw=(limits=Rect(-7,-10.0,0, 11,10,11), size=(800, 800)))
f = Figure()
sub = f[1, 1]
scene = LScene(sub)
text!(scene, "status", position=Point2f0(20, 0), fontsize=20, align=(:left, :bottom), space=:pixel)

We do have the space keyword now, which you can also use with e.g. relative.
See the docs:
https://docs.makie.org/stable/reference/plots/text/
The space keyword should be accepted by most plots these days.

That’s not right, fig[1, 1] is a GridPosition object and not a Scene. The call text!(scene,... must take some weird dispatch route by accident and end up putting the text in the current_axis() I think because it doesn’t recognize the first argument.

OK, I found a way to create a status line at the bottom.

Next question:
In the past I could use the line:

gl_screen = display(sceen)

to get a handle to the opengl screen, but this function does not exist any more (or is no longer exported). How can I achieve this now?

screen = display(figure)

1 Like

Finally everything works! About 12h of work for this update, but if you update only every 4 years that might be OK. Nevertheless looking forward for Makie 1.0 and less frequent breaking changes.
The new version v0.3.0 is available from: GitHub - aenarete/KiteViewers.jl: 3D viewer for airborne wind energy systems

Thanks a lot for the support of @sdanisch and @jules and @sijo ! :grinning:

3 Likes