-
Notifications
You must be signed in to change notification settings - Fork 136
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomers / easy to resolveGood for newcomers / easy to resolveplotting
Description
When using abmplot(...)
there is often a colobar with the heatmap. One can pass kwargs such as the color into this function.
Suppose I am setting up a plot and using the heatkwargs
variable, perhaps I can put label
here? Then if it is present the plot adds a label to the colorbar.
heatkwargs = (
colormap=[colorant"#174036", colorant"#cc4e5c"],
colorrange=(0, model.harvest_time),
label = "Plant age")
plotkwargs = (;
agent_color=agcolor,
agent_size=8,
agent_marker=agshape,
offset=aoffset,
agentsplotkwargs=(strokewidth=1.0, strokecolor=:black),
heatarray=arraycolor,
heatkwargs=heatkwargs,
)
Describe the solution you'd like
A clear and concise description of what you want to happen.
Here:
Agents.jl/ext/AgentsVisualizations/src/abmplot.jl
Lines 180 to 193 in 626e605
function heatmap!(ax, p::_ABMPlot) | |
heatobs = @lift(abmplot_heatobs($(p.abmobs[].model), p.heatarray[])) | |
isnothing(heatobs[]) && return nothing | |
hmap = Makie.heatmap!(p, heatobs; | |
colormap=JULIADYNAMICS_CMAP, p.heatkwargs...) | |
p.add_colorbar[] && Colorbar(ax.parent[1, 1][1, 2], hmap, width=20) | |
# TODO: Set colorbar to be "glued" to axis | |
# Problem with the following code, which comes from the tutorial | |
# https://makie.juliaplots.org/stable/tutorials/aspect-tutorial/ , | |
# is that it only works for axis that have 1:1 aspect ratio... | |
# rowsize!(fig[1, 1].layout, 1, ax.scene.px_area[].widths[2]) | |
# colsize!(fig[1, 1].layout, 1, Aspect(1, 1.0)) | |
return hmap | |
end |
and here:
Agents.jl/ext/AgentsVisualizations/src/abmplot.jl
Lines 96 to 132 in 626e605
@recipe(_ABMPlot, abmobs) do scene | |
Theme( | |
# TODO: insert JuliaDynamics theme here? | |
) | |
Attributes( | |
# Axis | |
# ax is currently necessary to have a reference to the parent Axis. This is needed | |
# for optional Colorbar of heatmap and optional buttons/sliders. | |
# Makie's recipe system still works on the old system of Scenes which have no | |
# concept of a parent Axis. Makie devs plan to enable this in the future. Until then | |
# we will have to work around it with this "little hack". | |
ax=nothing, | |
# Agent | |
agent_color=JULIADYNAMICS_COLORS[1], | |
agent_size=15, | |
agent_marker=:circle, | |
offset=nothing, | |
spaceplotkwargs = NamedTuple(), | |
agentsplotkwargs = NamedTuple(), | |
# Preplot | |
heatarray=nothing, | |
heatkwargs=NamedTuple(), | |
add_colorbar=true, | |
adjust_aspect=true, | |
# Interactive application | |
add_controls=false, | |
# Add parameter sliders if params are provided | |
params=Dict(), | |
# Animation evolution speed | |
dt=nothing, | |
# Internal Attributes necessary for inspection, controls, etc. to work | |
_used_poly=false, | |
) | |
end |
I just make my own plot for these situation and do not use the abmplot function.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomers / easy to resolveGood for newcomers / easy to resolveplotting