# Produce a heatmap for agents on a 2d grid with abmplot

**URL:** <https://discourse.julialang.org/t/produce-a-heatmap-for-agents-on-a-2d-grid-with-abmplot/101638>\
**Category:** Modelling & Simulations\
**Tags:** agents\
**Created:** [July 14, 2023, 9:48pm UTC](https://discourse.julialang.org/t/produce-a-heatmap-for-agents-on-a-2d-grid-with-abmplot/101638 "2023-07-14T21:48:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mantzaris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mantzaris/32/3852_2.png) [@mantzaris](https://discourse.julialang.org/u/mantzaris)\
**Post date:** [July 14, 2023, 9:48pm UTC](https://discourse.julialang.org/t/produce-a-heatmap-for-agents-on-a-2d-grid-with-abmplot/101638/1 "2023-07-14T21:48:36Z")

</div>

Given a agent based model (using Agents.jl) of agents on a 2d grid with values between 0-10 (continuous) is it possible to produce a heatmap using `abmplot`? (each agent has a Float param) If so what is a straightforward approach for that? Is there an approach which does not require an observable?

---

<div class="post-metadata">

**Author:** ![fbanning](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fbanning/32/14972_2.png) [@fbanning](https://discourse.julialang.org/u/fbanning)\
**Post date:** [July 17, 2023, 8:41am UTC](https://discourse.julialang.org/t/produce-a-heatmap-for-agents-on-a-2d-grid-with-abmplot/101638/2 "2023-07-17T08:41:03Z")

</div>

`abmplot` mostly only deals with the actual plotting, so you as a user still have to take care of the data that should be plotted. If you want to create a _simple_ heatmap, have a look at the [Preplot related subsection in the docs](https://juliadynamics.github.io/Agents.jl/stable/examples/agents_visualizations/#Agents.abmplot), specifically at the `heatarray` kwarg. If you fancy a more fancy heatmap, you can also use the `heatkwargs` kwarg to style it. And finally, if you want something a lot more involved, you can also just plot a `heatmap` plot yourself over/under the `abmplot` (but that would require basic knowledge of observables and the Makie ecosystem, I suppose).

---

<div class="post-metadata">

**Author:** ![mantzaris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mantzaris/32/3852_2.png) [@mantzaris](https://discourse.julialang.org/u/mantzaris)\
**Post date:** [July 17, 2023, 3:22pm UTC](https://discourse.julialang.org/t/produce-a-heatmap-for-agents-on-a-2d-grid-with-abmplot/101638/3 "2023-07-17T15:22:23Z")

</div>

Are there any examples to showcase how this can be done for heatmaps of agent properties using the different approaches which you recommend? eg. " `heatkwargs = NamedTuple()` : Keywords given to `Makie.heatmap` function if `heatarray` is not nothing"

---

<div class="post-metadata">

**Author:** ![fbanning](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fbanning/32/14972_2.png) [@fbanning](https://discourse.julialang.org/u/fbanning)\
**Post date:** [July 17, 2023, 4:13pm UTC](https://discourse.julialang.org/t/produce-a-heatmap-for-agents-on-a-2d-grid-with-abmplot/101638/4 "2023-07-17T16:13:39Z")

</div>

Sure thing: All the [heatmap examples listed in the Makie docs](https://docs.makie.org/stable/examples/plotting_functions/heatmap/) can be applied in the same way to the `abmplot` recipe via the `heatkwargs` keyword argument.

The `xs`, `ys`, and `zs` are determined by the `heatarray` input to `abmplot`. The `zs` are likely what you want to derive from your agent properties.
