MakieOrg / Makie.jl

Interactive data visualizations and plotting in Julia
https://docs.makie.org/stable
MIT License
2.38k stars 302 forks source link

Observables don't work with meshscatter #401

Open lmarcon1 opened 4 years ago

lmarcon1 commented 4 years ago

Hi to everyone and to SimonDanisch ,

First of all congrats for the project. I am trying to use a slider to select the data to plot in "meshscatter", but when I do it I get these errors:

setindex! at /home/jjsermor/.julia/packages/Observables/qCJWB/src/Observables.jl:83 [inlined] [29] #696 at /home/jjsermor/.julia/packages/AbstractPlotting/B5nOF/src/interaction/events.jl:29 [inlined] [30] (::getfield(Observables, Symbol("#g#15")){getfield(AbstractPlotting, Symbol("##696#697")){Base.RefValue{Bool},Base.RefValue{AbstractPlotting.Mouse.Button},Base.RefValue{AbstractPlotting.Mouse.DragEnum},Events},Tuple{Observables.Observable{Tuple{Float64,Float64}},Observables.Observable{Set{AbstractPlotting.Mouse.Button}}}})(::Tuple{Float64,Float64}) at /home/jjsermor/.julia/packages/Observables/qCJWB/src/Observables.jl:136 [31] #setindex!#1(::getfield(Observables, Symbol("##2#4")), ::Function, ::Observables.Observable{Tuple{Float64,Float64}}, ::Tuple{Float64,Float64}) at /home/jjsermor/.julia/packages/Observables/qCJWB/src/Observables.jl:87 [32] setindex! at /home/jjsermor/.julia/packages/Observables/qCJWB/src/Observables.jl:83 [inlined] [33] (::getfield(GLMakie, Symbol("#cursorposition#48")){Observables.Observable{Tuple{Float64,Float64}}})(::GLFW.Window, ::Float64, ::Float64) at /home/jjsermor/.julia/packages/GLMakie/5wmnA/src/events.jl:207 [34] _CursorPosCallbackWrapper(::GLFW.Window, ::Float64, ::Float64) at /home/jjsermor/.julia/packages/GLFW/e257h/src/callback.jl:43 [35] PollEvents at /home/jjsermor/.julia/packages/GLFW/e257h/src/glfw3.jl:585 [inlined] [36] #renderloop#36(::Float64, ::getfield(GLMakie, Symbol("##37#39")), ::Function, ::GLMakie.Screen) at /home/jjsermor/.julia/packages/GLMakie/5wmnA/src/rendering.jl:7 [37] renderloop(::GLMakie.Screen) at /home/jjsermor/.julia/packages/GLMakie/5wmnA/src/rendering.jl:2 [38] (::getfield(GLMakie, Symbol("##31#33")))() at ./task.jl:259

I am using this simple code:

using Makie
using Colors
timepoints = Array[]
 for i in 1:1000
      points=Point{3,Float32}[]
      for j in 1:i
         push!(points,Point3f0(rand(),rand(),rand()))
      end
      push!(timepoints,points)
 end
s1 = slider(collect(1:100))
currtpx=lift(s1[end][:value]) do idx
         timepoints[idx]
end
colors=lift(s1[end][:value]) do idx
        rand(idx)
end
scene2 = Scene()
hbox(meshscatter!(scene2,currtpx, camera=cam3d!, color=colors),s1)

If I use scatter! instead of meshscatter it works. However, I need to use meshscatter because I would like to plot some 3D geometries. Are observables working with meshscatter?

Thanks in advance

lmarcon1 commented 4 years ago

@SimonDanisch?

asinghvi17 commented 4 years ago

Observables don't work with meshscatter currently, because you can't change the mesh. I think that we had a workaround for that somewhere, or we could just delete the mesh and replot.

SimonDanisch commented 4 years ago

No, it's not about the mesh, changing that actually works (kinda ironic, since it seems more complicated)... Resizing the list of attributes per element doesn't work. You can pre allocate a larger array and then setting them to NaN or so should work...

melioristic commented 2 years ago

How can we delete the mesh and replot it? I am not sure whether this is about the meshplot or resizing of the elements. Any update here?