Makie scatter plot update issues

Hi,

I’m trying to make a GLMakie GUI with a draggable scatter plot. The dragging part works OK (it updated the positions), but when modifying the number of points plotted, the scatter plot only shows the initial number of points.
Here is an illustration of the problem, after pressing ‘a’ a few times to add more points, the scatter plot is not updated properly (number of markers stay the same). The line plot works fine.

using GLMakie, Observables


function minimal_gui()

    fig = Figure()
    ax = Axis(fig[1,1])

    PTS = Observable(rand(Point2f, 5))

    lines!(ax, PTS, color = :grey)


    # my_markers = @lift map(i -> isodd(i) ? :circle : :diamond, eachindex($PTS))
    my_markers = lift(PTS) do pts

        [ isodd(i) ? :circle : :diamond for i in eachindex(pts)]
    end

    scatter!(ax, PTS, marker = my_markers, markersize = 10)

    on(events(ax).keyboardbutton, priority = 10) do event
        if event.action == Keyboard.press && event.key == Keyboard.a
            
            pts = PTS[]
            push!(pts, rand(Point2f))
            PTS[] = pts
            
        return Consume(true)
        end
        return Consume(false)
    end

    return fig
end

This is how it looks:

I also tried doing something like this (delete & recreate the plot when PTS changes):

scatter_plot = Observable(scatter!(ax, PTS, ...)) 
scatter_plot = lift(PTS) do pts
    delete!(ax, scatter_plot[]
    markers  = ...
  sizes = ...
  scatter!(ax, ...)
end

This works, but resets the zoom level EVERY TIME I drag the points, which is very annoying. I’m
fine with either method if it can be made to work without these weird issues.

Many thanks!

This a bug where a computation down the line checks wrong input for changes. Until we merge and release a fix, you can add

...
PTS[] = pts

s.font = "Fira Mono"
s.font = "default"

return Consume(true)

to the callback. That will mark the checked input as changed.

Fixed in Fix `marker` updates not propagating in `scatter` by ffreyer · Pull Request #5451 · MakieOrg/Makie.jl · GitHub