[ANN] Makie v.0.13

PlotlyJS was the culprit. Thanks :slight_smile:

Makie is a fantastic package for plotting , I would like to congratulate the team. I have no doubt that Makie will soon replace plots. :grinning: :grinning: :grinning: :grinning:

But when I upgraded from v0.13.7 to v0.13.8 it crashed with the following error by using Windows 10 :cry: :cry:

ERROR: LoadError: MethodError: no method matching backend_show(::Missing, ::IOContext{IOStream}, ::MIME{Symbol("image/svg+xml")}, ::Makie.Scene)
Closest candidates are:
  backend_show(::Any, ::IO, ::MIME{Symbol("text/plain")}, ::Makie.Scene) at C:\Users\pollaccoj\.julia\packages\Makie\ZK3qM\src\display.jl:89
Stacktrace:
  [1] show(io::IOContext{IOStream}, m::MIME{Symbol("image/svg+xml")}, scene::Makie.Scene)
    @ Makie C:\Users\pollaccoj\.julia\packages\Makie\ZK3qM\src\display.jl:118
  [2] (::Makie.var"#900#901"{Float64, Float64, DataType, Makie.Scene})(s::IOStream)
    @ Makie C:\Users\pollaccoj\.julia\packages\Makie\ZK3qM\src\display.jl:249
  [3] open(::Makie.var"#900#901"{Float64, Float64, DataType, Makie.Scene}, ::String, ::Vararg{String, N} where N; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Base .\io.jl:330
  [4] open
    @ .\io.jl:328 [inlined]
  [5] save(file::FileIO.File{FileIO.DataFormat{:SVG}, String}, fig::Makie.Figure; resolution::Tuple{Int64, Int64}, pt_per_unit::Float64, px_per_unit::Float64)
    @ Makie C:\Users\pollaccoj\.julia\packages\Makie\ZK3qM\src\display.jl:243
  [6] save(file::FileIO.File{FileIO.DataFormat{:SVG}, String}, fig::Makie.Figure)
    @ Makie C:\Users\pollaccoj\.julia\packages\Makie\ZK3qM\src\display.jl:231
  [7] save(filename::String, fig::Makie.Figure; args::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie C:\Users\pollaccoj\.julia\packages\Makie\ZK3qM\src\display.jl:222
  [8] save(filename::String, fig::Makie.Figure)
    @ Makie C:\Users\pollaccoj\.julia\packages\Makie\ZK3qM\src\display.jl:222

When I run Test Makie I get the following warning which might be helpful for debugging:

WARNING: using GeometryBasics.volume in module ReferenceTests conflicts with an existing identifier.

I opened an Issue #989 on the Makie GitHub.

Replace in what context?

I present this alert when trying to reset the GLMakie v0.4.2 package. What should I do?

(@v1.6) pkg> test GLMakie
     Testing GLMakie
┌ Warning: Could not use exact versions of packages in manifest, re-resolving
└ @ Pkg.Operations C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\Operations.jl:1526
ERROR: expected package `ReferenceTests [d37af2e0]` to be registered

julia> versioninfo()
Julia Version 1.6.1
Commit 6aaedecc44 (2021-04-23 05:59 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: AMD Ryzen 7 1800X Eight-Core Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, znver1)

julia>

duplicate of Makie - Testing GLMakie with correct ReferenceTests - #2 by sdanisch

“Minimal code changes necessary” — this whole restructuring broke almost every line of my mesh-animation code…

Can you share what you’ve run into?
I don’t think we made any big changes, besides the big Vec3f0 → Vec3f conversion, which should be easily fixable with the script from: https://github.com/JuliaGeometry/GeometryBasics.jl/pull/97#issue-714149607

It might be a later version (apparently v0.15 is the current one).

Anyway my old code is:

scene = Scene(
    show_axis = false,
    resolution = (1920, 1080)
)
camera(scene)
mesh!(
    Mesh(drop.mesh),
    #color = RGBAf0(0, 0, 1, 0.5),
    color = :blue,
    shading = true,
)
xs = -1.5:1e-2:1.5
r0 = center_of_mass(drop)
surface!(
    xs,
    xs,
    zeros(Float32, length(xs), length(xs)),
    color = [
        convert(
            RGBAf0,
            mycmap(90 / 360 * 2pi)
        ) for x in xs, y in xs
    ],
    shading = false
)
update_cam!(scene, cameracontrols(scene), Vec3f0(2.5, 0, 1), Vec3f0(0), Vec3f0(0, 0, 1))
scene |> display

record(
    scene,
    joinpath(trajectory.datapath, "anim3d.mp4"),
    -30:2:1000,
    framerate = 30
) do t
    i = findlast(<=(t), trajectory.times)
    i = isnothing(i) ? -1 : i
    t, (drop, subs) = trajectory[max(1, i)]
    r0 = center_of_mass(drop)
    scene.plots[1].input_args[1][] = Mesh(drop.mesh)
    if i > 0
        scene.plots[2][:color] = [
            convert(
                RGBAf0,
                target_angle(drop, subs, t, SVector(x, y, 0), r0) |> mycmap
            ) for x in xs, y in xs
        ]
    else
        scene.plots[2][:color] = [
            convert(
                RGBAf0,
                mycmap(90 / 360 * 2pi)
            ) for x in xs, y in xs
        ]
    end
end

I got it mostly working again like so:

#fig = Figure()
#ax = Axis3(fig, show_axis = false,    resolution = (1920, 1080))
#cam = Camera3D(fig.scene)

fig, ax, drop_plot = mesh(
    Mesh(drop.mesh),
    #color = RGBAf0(0, 0, 1, 0.5),
    color = :blue,
    #colormap = (:white, :white),
    shading = false,
    figure = (resolution = (1920, 1080),),
    #lightposition = Vec3f0(0, 1, 2),
    #diffuse = Vec3f0(0.5, 0.5, 0.5),
    #ambient = Vec3f0(0.5,0.5,0.6),
    #shininess = 128f0,
)
xs = -1.5:1e-2:1.5
r0 = center_of_mass(drop)
subs_plot = surface!(
    xs,
    xs,
    zeros(Float32, length(xs), length(xs)),
    color = [
        convert(
            RGBAf0,
            mycmap(90 / 360 * 2pi)
        ) for x in xs, y in xs
    ],
    shading = false
)
scene = fig.scene
#update_cam!(scene, cam, Vec3f0(2.5, 0, 1), Vec3f0(0), Vec3f0(0, 0, 1))
#scene |> display
Makie.get_scene(fig) |> display

record(
    fig,
    joinpath(trajectory.datapath, "anim3d.mp4"),
    -120:10:2000,
    framerate = 30
) do t
    i = findlast(<=(t), trajectory.times)
    i = isnothing(i) ? -1 : i
    t, (drop, subs) = trajectory[max(1, i)]
    r0 = center_of_mass(drop)
    drop_plot.input_args[1][] = Mesh(drop.mesh)
    if i > 0
        subs_plot.color = [
            convert(
                RGBAf0,
                target_angle(drop, subs, t, SVector(x, y, 0), r0) |> mycmap
            ) for x in xs, y in xs
        ]
    else
        subs_plot.color = [
            convert(
                RGBAf0,
                mycmap(90 / 360 * 2pi)
            ) for x in xs, y in xs
        ]
    end
end

Notably, update_camera still doesnt work, and Vec3f is still Vec3f0 for some reason.

My main gripe is that there is no backwards compatibility, and no obvious place to find what replaced what. It’s just trial and error after each update

It looks like you skipped many major versions, from what I can tell…
This is always a bit of a struggle.
We also have become better at documenting breaking changes in NEWS.md + release notes and be more careful about deprecations - it’s still not perfect, but I’m pretty sure we had worse documentation for the versions you skipped.

3 Likes

Yes, that’s likely true. I avoided updating for a long time because I couldnt afford to break anything.

What’s not working with the old code? Scene is still around and if you don’t need layouting or an axis it’s not a bad idea to use that.

For the second version you should be using

ax = LScene (fig[1, 1], scenekw = (show_axis = false, ))
...
cam = cameracontrols(ax.scene)
update_cam!(ax.scene, cam, ...) 

Axis3 doesn’t have a camera the way scene had and fig.scene is not the 3d scene you’re drawing to.

Thanks. That really begs the question though: Why isn’t fig.scene the scene that I’m drawing to? Where did I create a different scene?

The figure has its own top level scene with a PixelCamera which means all plot objects there are drawn in 2D, and a line from 0,0 to 100,0 is 100 pixels long. If you place an LScene in the Figure (which you only need because the normal Scene doesn’t have the infrastructure to connect to a layout) then you get a new child scene wrapped in there, accessible under lscene.scene, and for that you can manipulate the camera however you want. Axis3 is really only for that very specific 3D axis in a layout look.

I think was able to follow that. But I could not make your suggested camera code work and tbh it’s intensely all alienating. Why does the figure come with a PixelCamera that is effectively unusable? (rhetorical question) I think somewhere there needs to be a design document that explains how I’m actually supposed to interact with this labyrinthean system of Cameras, Figures, Scenes, Axes, Layout, etc. It’s impenetrable (even for someone who has already worked a lot with PyPlot and Plots.jl)

1 Like

Maybe it would be more goal oriented to open specific issues in the Makie repo or here in separate threads. Reviving an older topic such as this for voicing your frustration with the package doesn’t really lead to actionable improvements I fear. A lot of effort went into the documentation that explains the connection between the parts you have trouble with, so opening docs issues or PRs that relate to those specific points would be highly appreciated.

5 Likes

Right now I’m trying to make a heatmap using Makie, but the plots are upside down. How can I reverse the y-axis?

There’s an example of the different orientation options here image