Artists
This module is used to draw agents and geographies on the canvas. The honeybees.artists.Artists
can be extended, see Visualisation, by adding functions named draw_{agent_name} or draw_{geography_name}. In addition, the relevant options in the config-file MUST be turned on. An example is given below. Any additional arguments specified in the config-file are also passed on as arguments to the respective function in honeybees.artists.Artists
.
In artists.py:
class Artists(Artists):
def __init__(self, model):
Artists.__init__(self, model)
def draw_people(self, model, agents, idx): # agent
return {"type": "shape", "shape": "circle", "r": 2, "filled": True, "color": 'Red'}
def draw_rivers(self, color): # geography
return {"type": "shape", "shape": "line", "color": color}
in config.yml:
draw:
draw_agents:
people:
draw_every_nth: 1
draw_geography:
rivers:
colors: green
cities:
The return type of the drawing functions in the honeybees.artists.Artists
must be one of the following:
Point:
{"type": "shape", "shape": "circle", "r": 1, "filled": True, "color": 'blue'}
Line or multi-line:
{"type": "shape", "shape": "line", "color": "Blue"}
Polygon or multi-polygon:
{"type": "shape", "shape": "polygon", "color": "Blue", "filled": True}
It is also possible to update a geography at timesteps. To do so, a function called update_{geography_name} must be specified in honeybees.artists.Artists
. This function takes as argument the ID of the geography (as specified in the geojson passed to the model) and the current portrayal of the geography allowing you to update the parameters of the portrayal. For example:
def update_cities(self, ID, portrayal):
portrayal['color'] = random.choice(['Green', 'Orange', 'Blue', "Red", 'Purple', 'Pink'])
return portrayal