# How to display dynamic value for each agent in interactive plot

**URL:** <https://discourse.julialang.org/t/how-to-display-dynamic-value-for-each-agent-in-interactive-plot/136361>\
**Category:** General Usage\
**Tags:** question, agents, makie\
**Created:** [March 24, 2026, 12:47pm UTC](https://discourse.julialang.org/t/how-to-display-dynamic-value-for-each-agent-in-interactive-plot/136361 "2026-03-24T12:47:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Post date:** [March 24, 2026, 12:47pm UTC](https://discourse.julialang.org/t/how-to-display-dynamic-value-for-each-agent-in-interactive-plot/136361/1 "2026-03-24T12:47:02Z")

</div>

Hello,

I am using Agents.jl and I would like to plot a value for each agent dynamically with [abmplot](https://juliadynamics.github.io/Agents.jl/stable/examples/agents_visualizations/#Agents.abmplot-examples-agents_visualizations) with `enable_inspection = true`. This [example](https://juliadynamics.github.io/AgentsExampleZoo.jl/dev/examples/hk/) shows how to generate a static plot of this variety ([here](https://juliadynamics.github.io/AgentsExampleZoo.jl/dev/examples/hk/d600e57a.png) is the plot). But its not clear to me how this can be done.

Specifically, if I have in pseudo-code:

```julia
fig, ax, abmods = abmplot(..., enable_inspection = true)
widget_layout = fig[end + 1, :] = GridLayout()
plot_layout = widget_layout[1,1] = GridLayout()
ax_plot = Axis(plot_layout[1,1])
# throws error cannot convert Vector{Float64} to Float64
lines!(ax_plot, @lift(Point2f.($(abmods.mdf).time, $(abmods.mdf).beliefs)))

```

How do I modify the last line to support `Vector{Float64}`? I can add a runnable version of the code if that would be helpful.

---

<div class="post-metadata">

**Author:** ![asinghvi17](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/asinghvi17/32/8272_2.png) [@asinghvi17](https://discourse.julialang.org/u/asinghvi17)\
**Post date:** [March 24, 2026, 9:19pm UTC](https://discourse.julialang.org/t/how-to-display-dynamic-value-for-each-agent-in-interactive-plot/136361/2 "2026-03-24T21:19:24Z")

</div>

Could you tell me what the type of `abmods.mdf`, `abmods.mdf[].time`, and `abmods.mdf[].beliefs` is? Or the full error message?

Without that it’s a bit hard to understand what is going on 😅

---

<div class="post-metadata">

**Author:** ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Post date:** [March 24, 2026, 9:35pm UTC](https://discourse.julialang.org/t/how-to-display-dynamic-value-for-each-agent-in-interactive-plot/136361/3 "2026-03-24T21:35:43Z")

</div>

Thank you for your reply. I can provide a MWE tomorrow if that would be helpful. For now, I can tell you that `abmobs.mdf.val.time` is a `Vector{Int}` and `abmods.mdf.val.beliefs` is `Vector{Vector{Float64}}`, but according to the error message below, it is expecting `Float32`. I think the problem is that on each iteration, it is expecting a scalar, but it is receiving a vector containing the belief state of each agent. Again, if that doesn’t help, I can simplify the model tomorrow and post it tomorrow.

> **Summary**
>
> ```julia
> ERROR: MethodError: Cannot `convert` an object of type Vector{Float64} to an object of type Float32
> The function `convert` exists, but no method is defined for this combination of argument types.
> 
> Closest candidates are:
> convert(::Type{T}, ::Ratios.SimpleRatio{S}) where {T<:AbstractFloat, S}
> @ Ratios C:\Users\christopher.fisher\.julia\packages\Ratios\FsiCW\src\Ratios.jl:51
> convert(::Type{T}, ::IntervalArithmetic.ExactReal) where T<:Real
> @ IntervalArithmetic C:\Users\christopher.fisher\.julia\packages\IntervalArithmetic\f3Gip\src\intervals\exact_literals.jl:130
> convert(::Type{T}, ::Unit) where T<:Number
> @ Makie C:\Users\christopher.fisher\.julia\packages\Makie\kJl0u\src\units.jl:29
> ...
> 
> Stacktrace:
> [1] macro expansion
> @ C:\Users\christopher.fisher\.julia\packages\StaticArraysCore\MoJEf\src\StaticArraysCore.jl:95 [inlined]
> [2] convert_ntuple
> @ C:\Users\christopher.fisher\.julia\packages\StaticArraysCore\MoJEf\src\StaticArraysCore.jl:91 [inlined]
> [3] Point{2, Float32}(x::Tuple{Int64, Vector{Float64}})
> @ GeometryBasics C:\Users\christopher.fisher\.julia\packages\GeometryBasics\yB1f1\src\fixed_arrays.jl:21
> [4] StaticArray
> @ C:\Users\christopher.fisher\.julia\packages\StaticArrays\0cEwi\src\convert.jl:173 [inlined]      
> [5] _broadcast_getindex_evalf
> @ .\broadcast.jl:699 [inlined]
> [6] _broadcast_getindex
> @ .\broadcast.jl:672 [inlined]
> [7] _getindex
> @ .\broadcast.jl:620 [inlined]
> [8] getindex
> @ .\broadcast.jl:616 [inlined]
> [9] copy
> @ .\broadcast.jl:933 [inlined]
> [10] materialize(bc::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{…}, Nothing, Type{…}, Tuple{…}})
> @ Base.Broadcast .\broadcast.jl:894
> [11] (::var"#62#63")(arg1#290::DataFrames.DataFrame)
> @ Main .\none:-1
> [12] #map#11
> @ C:\Users\christopher.fisher\.julia\packages\Observables\YdEbO\src\Observables.jl:570 [inlined]  
> 
> ```

---

<div class="post-metadata">

**Author:** ![mikmoore](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikmoore/32/31109_2.png) [@mikmoore](https://discourse.julialang.org/u/mikmoore)\
**Post date:** [March 24, 2026, 10:43pm UTC](https://discourse.julialang.org/t/how-to-display-dynamic-value-for-each-agent-in-interactive-plot/136361/4 "2026-03-24T22:43:44Z")

</div>

Are you looking for [`series`/`series!`](https://docs.makie.org/dev/reference/plots/series) to plot a variable number of items?

---

<div class="post-metadata">

**Author:** ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Post date:** [March 25, 2026, 9:11am UTC](https://discourse.julialang.org/t/how-to-display-dynamic-value-for-each-agent-in-interactive-plot/136361/5 "2026-03-25T09:11:34Z")

</div>

This was a promising suggestion, but unfortunately it leads to a similar error. It looks like `series!` requires an 2 dimensional array in which rows correspond to separate lines. I am wondering whether the source of the problem is the way `@lift` accumulates observations from `$(abmods.mdf).get_mean_beliefs)`.

---

<div class="post-metadata">

**Author:** ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Post date:** [March 25, 2026, 9:15am UTC](https://discourse.julialang.org/t/how-to-display-dynamic-value-for-each-agent-in-interactive-plot/136361/6 "2026-03-25T09:15:15Z")

</div>

As promised, I created a simplified MWE of my model to help arrive at a solution. I also included the version info for future reference.

> **MWE**
>
> ```julia
> using Agents
> using GLMakie
> using Statistics
> 
> @agent struct HKAgent(GridAgent{2})
> beliefs::Float64
> end
> 
> function hk_model(; numagents = 100, ϵ = 0.2)
> space = GridSpaceSingle((20, 20))
> model = StandardABM(HKAgent, space; agent_step!, model_step!, scheduler = Schedulers.fastest, properties = Dict(:ϵ => ϵ))
> for i in 1:numagents
> o = rand(abmrng(model))
> add_agent_single!(model, o)
> end
> return model
> end
> 
> function boundfilter(agent, model)
> filter(
> j -> abs(agent.beliefs - j) < model.ϵ,
> [a.beliefs for a in allagents(model)],
> )
> end
> 
> function agent_step!(agent, model)
> agent.beliefs = mean(boundfilter(agent, model))
> end
> 
> model_step!(model) = nothing
> 
> get_beliefs(model) = [a.beliefs for a ∈ allagents(model)]
> get_mean_beliefs(model) = mean(get_beliefs(model))
> 
> model = hk_model(; numagents = 100, ϵ = 0.2)
> # _, df_model = run!(model, 20; mdata = [get_beliefs])
> 
> fig, ax, abmods = abmplot(model, enable_inspection = true, add_controls = true, mdata = [get_beliefs, get_mean_beliefs])
> 
> widget_layout = fig[end + 1, :] = GridLayout()
> plot_mean_layout = widget_layout[1,1] = GridLayout()
> ax_mean_beliefs = Axis(plot_mean_layout[1,1])
> lines!(ax_mean_beliefs, @lift(Point2f.($(abmods.mdf).time, $(abmods.mdf).get_mean_beliefs)))
> 
> plot_individual_layout = widget_layout[2,1] = GridLayout()
> ax_individual_beliefs = Axis(plot_individual_layout[1,1])
> # for testing: runs with commented code
> # lines!(ax_individual_beliefs, @lift(Point2f.($(abmods.mdf).time, $(abmods.mdf).get_mean_beliefs)))
> # original failing code
> # lines!(ax_individual_beliefs, @lift(Point2f.($(abmods.mdf).time, $(abmods.mdf).get_beliefs)))
> series!(ax_individual_beliefs, @lift(Point2f.($(abmods.mdf).time, $(abmods.mdf).get_beliefs)))
> 
> on(abmods.model) do m
> autolimits!(ax_mean_beliefs)
> autolimits!(ax_individual_beliefs)
> end
> fig
> 
> ```

> **Error**
>
> ```julia
> ERROR: MethodError: Cannot `convert` an object of type Vector{Float64} to an object of type Float32
> The function `convert` exists, but no method is defined for this combination of argument types.
> 
> Closest candidates are:
> convert(::Type{T}, ::IntervalArithmetic.ExactReal) where T<:Real
> @ IntervalArithmetic ~/.julia/packages/IntervalArithmetic/f3Gip/src/intervals/exact_literals.jl:130
> convert(::Type{T}, ::Unit) where T<:Number
> @ Makie ~/.julia/packages/Makie/kJl0u/src/units.jl:29
> convert(::Type{T}, ::T) where T<:Number
> @ Base number.jl:6
> ...
> 
> Stacktrace:
> [1] macro expansion
> @ ~/.julia/packages/StaticArraysCore/MoJEf/src/StaticArraysCore.jl:95 [inlined]
> [2] convert_ntuple
> @ ~/.julia/packages/StaticArraysCore/MoJEf/src/StaticArraysCore.jl:91 [inlined]
> [3] Point{2, Float32}(x::Tuple{Int64, Vector{Float64}})
> @ GeometryBasics ~/.julia/packages/GeometryBasics/yB1f1/src/fixed_arrays.jl:21
> [4] StaticArray
> @ ~/.julia/packages/StaticArrays/0cEwi/src/convert.jl:173 [inlined]
> [5] _broadcast_getindex_evalf
> @ ./broadcast.jl:699 [inlined]
> [6] _broadcast_getindex
> @ ./broadcast.jl:672 [inlined]
> [7] _getindex
> @ ./broadcast.jl:620 [inlined]
> [8] getindex
> @ ./broadcast.jl:616 [inlined]
> [9] copy
> @ ./broadcast.jl:933 [inlined]
> [10] materialize(bc::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{…}, Nothing, Type{…}, Tuple{…}})
> @ Base.Broadcast ./broadcast.jl:894
> [11] (::var"#40#41")(arg1#280::DataFrames.DataFrame)
> @ Main ./none:-1
> [12] #map#11
> @ ~/.julia/packages/Observables/YdEbO/src/Observables.jl:570 [inlined]
> [13] map(::var"#40#41", ::Observable{DataFrames.DataFrame})
> @ Observables ~/.julia/packages/Observables/YdEbO/src/Observables.jl:568
> [14] top-level scope
> @ REPL[38]:5
> Some type information was truncated. Use `show(err)` to see complete types.
> 
> ```

> **Version Info**
>
> ``julia  
> (abm\_multi\_line) pkg\> st  
> Status `~/.julia/dev/sandbox/abm_multi_line/Project.toml`  
> [46ada45e] Agents v7.0.1  
> [e9467ef8] GLMakie v0.13.9
> 
> ```julia-auto
> 
> ```
