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

add missing vertical red line on reset #110

Merged
merged 1 commit into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/agents/convenience.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ function abmexploration(model;
fig, ax, (p, abmplot_object) = abmplot(model;
_add_interaction = false, figure = (resolution = (1600, 800),), kwargs...)

stepclick = add_interaction!(fig, ax, abmplot_object)
stepclick, resetclick = add_interaction!(fig, ax, abmplot_object)

adata, mdata = p.adata, p.mdata
!isnothing(adata) && @assert eltype(adata)<:Tuple "Only aggregated agent data are allowed."
!isnothing(alabels) && @assert length(alabels) == length(adata)
!isnothing(mlabels) && @assert length(mlabels) == length(mdata)
init_abm_data_plots!(fig, p, adata, mdata, alabels, mlabels, plotkwargs, stepclick)
init_abm_data_plots!(fig, p, adata, mdata, alabels, mlabels, plotkwargs, stepclick, resetclick)
return fig, p
end

function init_abm_data_plots!(fig, p, adata, mdata, alabels, mlabels, plotkwargs, stepclick)
function init_abm_data_plots!(fig, p, adata, mdata, alabels, mlabels, plotkwargs, stepclick, resetclick)
La = isnothing(adata) ? 0 : size(p.adf[])[2]-1
Lm = isnothing(mdata) ? 0 : size(p.mdf[])[2]-1
La + Lm == 0 && return nothing # failsafe; don't add plots if dataframes are empty
Expand Down Expand Up @@ -98,6 +98,11 @@ function init_abm_data_plots!(fig, p, adata, mdata, alabels, mlabels, plotkwargs
ylims!(ax, Makie.MakieLayout.yautolimits(ax))
end
end
on(resetclick) do clicks
for ax in axs
vlines!(ax, [p.s.val], color = "#c41818")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#c41818

Was this the colour we've used in the earlier version?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah--I just found the last version of the code that had the colored line, and basically tried to modify it as little as possible to make it work after your refactor.

end
end
return nothing
end

Expand Down
2 changes: 1 addition & 1 deletion src/agents/interaction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function add_interaction!(fig, ax, abmplot)
add_param_sliders!(fig, abmplot.abmobs[].model, abmplot.params[], resetclick)
end

return stepclick
return stepclick, resetclick
end

"Initialize standard model control buttons."
Expand Down