Skip to content
This repository has been archived by the owner on Jun 21, 2024. It is now read-only.

Commit

Permalink
extent to GridSpaceSingle (#100)
Browse files Browse the repository at this point in the history
* extent to GridSpaceSingle

* correct abstarct type in limits

* remove unecessary instructions
  • Loading branch information
Datseris committed Jul 6, 2022
1 parent c195ebd commit e408c11
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
13 changes: 3 additions & 10 deletions src/agents/abmplot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,7 @@ Requires `Agents`. See also [`abmvideo`](@ref) and [`abmexploration`](@ref).
* `add_colorbar = true` : Whether or not a Colorbar should be added to the right side of the
heatmap if `heatarray` is not nothing.
* `static_preplot!` : A function `f(ax, model)` that plots something after the heatmap
but before the agents. Notice that you can still make objects of this plot be visible
above the agents using a translation in the third dimension like below:
```julia
function static_preplot!(ax, model)
obj = scatter!(ax, [50 50]; color = :red) # Show position of teacher
hidedecorations!(ax) # hide tick labels etc.
translate!(obj, 0, 0, 5) # be sure that the teacher will be above students
end
```
but before the agents.
* `osmkwargs = NamedTuple()` : keywords directly passed to
`osmplot!` from OSMMakie.jl if model space is `OpenStreetMapSpace`.
Expand Down Expand Up @@ -196,6 +188,7 @@ end

const SUPPORTED_SPACES = Union{
Agents.GridSpace,
Agents.GridSpaceSingle,
Agents.ContinuousSpace,
Agents.OpenStreetMapSpace,
}
Expand Down Expand Up @@ -277,7 +270,7 @@ function set_axis_limits!(ax, model)
elseif model.space isa Agents.ContinuousSpace
e = model.space.extent
o = zero.(e)
elseif model.space isa Agents.DiscreteSpace
elseif model.space isa Agents.AbstractGridSpace
e = size(model.space) .+ 0.5
o = zero.(e) .+ 0.5
end
Expand Down
4 changes: 2 additions & 2 deletions src/agents/lifting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function abmplot_pos(model::Agents.ABM{<:Agents.OpenStreetMapSpace}, offset, ids
end

agents_space_dimensionality(abm::Agents.ABM) = agents_space_dimensionality(abm.space)
agents_space_dimensionality(::Agents.GridSpace{D}) where {D} = D
agents_space_dimensionality(::Agents.AbstractGridSpace{D}) where {D} = D
agents_space_dimensionality(::Agents.ContinuousSpace{D}) where {D} = D
agents_space_dimensionality(::Agents.OpenStreetMapSpace) = 2

Expand Down Expand Up @@ -80,7 +80,7 @@ function abmplot_markersizes(model, as, ids)
markersizes = begin
if as isa Function
[as(model[i]) for i in ids]
else
else
as
end
end
Expand Down

0 comments on commit e408c11

Please sign in to comment.