Open EwoutH opened 3 days ago
In think (in Altair) it's called a Mark: https://altair-viz.github.io/user_guide/marks/index.html
Hi, was thinking about using the below, which use the Encode function attribute
has_shape = "shape" in all_agent_data[0]
if has_shape:
encoding_dict["shape"] = agent_data["shape"]
has_fill = "fill" in all_agent_data[0]
if has_shape:
encoding_dict["fill"] = agent_data["fill"]
The provided code snippet checks for shape
and fill
keys in agent data. If present, it adds them to the encoding_dict using the corresponding keys shape
and fill
. This allows you to define visual properties like circle shapes and filled elements for agents in your visualization.
Looks like a good start! I think it does need to be passed to Altair or matplotlib later in the code.
Feel free to open a (draft) PR!
In the old visualisation you could add values like
"Shape": "circle"
and"Filled": "true"
to theagent_portrayal
dict.With the new Solara based visualisation, that's not yet possible. It should be implemented in mesa/visualization/components. Somewhere around here: https://github.com/projectmesa/mesa/blob/74e2df6fdfc2d5172f84eb96469b277b35bfd795/mesa/visualization/components/altair.py#L50-L55 and maybe also in: https://github.com/projectmesa/mesa/blob/74e2df6fdfc2d5172f84eb96469b277b35bfd795/mesa/visualization/components/matplotlib.py#L40-L47