Closed asgolovin closed 1 year ago
Merging #863 (623e1d7) into main (e2e4384) will decrease coverage by
0.06%
. The diff coverage is0.00%
.
@@ Coverage Diff @@
## main #863 +/- ##
==========================================
- Coverage 70.94% 70.89% -0.06%
==========================================
Files 42 42
Lines 2795 2797 +2
==========================================
Hits 1983 1983
- Misses 812 814 +2
Files Changed | Coverage Δ | |
---|---|---|
ext/AgentsVisualizations/src/abmplot.jl | 0.00% <0.00%> (ø) |
:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more
Thanks a lot for the fix, very much appreciated!!
But this doesn't seem to solve the issue entirely, on my computer running the code in #827 gives, when finally calling fig
, this error:
julia> fig
Error showing value of type Figure:
ERROR: Buffer thickness does not have the same length as the other buffers.
color has length 56
vertex has length 56
thickness has length 84
Does it happen also on your computer or the graph is showed correctly?
Thanks a lot for the fix, very much appreciated!!
But this doesn't seem to solve the issue entirely, on my computer running the code in #827 gives, when finally calling
fig
, this error:julia> fig Error showing value of type Figure: ERROR: Buffer thickness does not have the same length as the other buffers. color has length 56 vertex has length 56 thickness has length 84
Stacktrace Does it happen also on your computer or the graph is showed correctly?
@Tortar, I can confirm that I also get this new problem after the fix from @asgolovin.
But the new error is easy to solve: you can just comment out the edge_width
variable from the graphplotkwargs
within the example I provided in #827.
I think this PR should be accepted! Thank you @asgolovin
thanks @AldoGl to have tried it out!
I actually fixed the code without commenting out that section:
using Agents
using ColorTypes
using Graphs
using GLMakie
using Graphs: edges
using GraphMakie: Shell
using GraphMakie: graphplot!
using GraphMakie: graphplot
sir_model, sir_agent_step!, sir_model_step! = Models.sir()
city_size(agents_here) = 0.005 * length(agents_here)
function city_color(agents_here)
return RGB(0.5 , 0.5, 0)
end
edge_color(model) = fill((:grey, 0.25), ne(model.space.graph))
function edge_width(model)
w = zeros(ne(model.space.graph))
for e in edges(model.space.graph)
w[e.src] = 0.004 * length(model.space.stored_ids[e.src])
w[e.dst] = 0.004 * length(model.space.stored_ids[e.dst])
end
return w
end
graphplotkwargs = (
layout = Shell(), # node positions
arrow_show = false, # hide directions of graph edges
edge_color = edge_color, # change edge colors and widths with own functions
edge_width = edge_width,
edge_plottype = :linesegments # needed for tapered edge widths
)
fig, ax, abmobs = abmplot(sir_model;
agent_step! = sir_agent_step!, model_step! = sir_model_step!,
as = city_size, ac = city_color, graphplotkwargs)
fig
Indeed this was a problem in the example itself :-)
so the example can be fixed in another PR anyway
Fixes #827
The plotting recipe for graphs uses the
graphplot!
function from GraphMakie, but GraphMakie is not listed in dependencies and is never imported. This very short PR fixes this.I added GraphMakie as a weak dependency since this is how other Makie libraries are listed, hope that's okay. :)