InteractiveDynamics.jl
InteractiveDynamics.jl copied to clipboard
`ERROR: LoadError: Invalid text boundingbox` with colorbars/heatarrays
MWE:
using Agents
using InteractiveDynamics
import GLMakie
@agent Person GridAgent{2} begin
wealth::Int
end
function agent_step!(agent, abm)
agent.wealth == 0 && return # do nothing
na = collect(nearby_ids(agent, abm))
if !isempty(na)
n = rand(abm.rng, na)
abm[n].wealth += 1
agent.wealth -= 1
end
end
# with filled space
function wealth_abm_filled(; dims = (25, 25), init = 4)
space = GridSpace(dims, periodic = true)
abm = ABM(Person, space; scheduler = Schedulers.randomly)
fill_space!(abm, init)
return abm
end
abm = wealth_abm_filled()
function wealthmap(abm)
m = zeros(Int, size(abm.space))
for pos in positions(abm)
for a in agents_in_position(pos, abm)
m[pos[1], pos[2]] += a.wealth
end
end
return m
end
cmap = GLMakie.cgrad(:tokyo, 100)
ac(a) = cmap[a.wealth/10]
abm_play(abm, agent_step!, dummystep; ac, heatarray = wealthmap)
and I get:
ERROR: LoadError: Invalid text boundingbox
Stacktrace:
[1] error(s::String)
@ Base .\error.jl:33
[2] boundingbox(glyphcollection::Makie.GlyphCollection, position::GeometryBasics.Point{3, Float32}, rotation::Makie.Quaternionf0)
@ Makie ~\.julia\packages\Makie\NL7Xw\src\layouting\boundingbox.jl:121
(followed by 10 pages of error stacktraces because error messages in Julia are abysmal)