projectmesa / mesa

Mesa is an open-source Python library for agent-based modeling, ideal for simulating complex systems and exploring emergent behaviors.
https://mesa.readthedocs.io
Apache License 2.0
2.45k stars 874 forks source link

Refactor altair in line with matplotlib #2435

Open quaquel opened 1 week ago

quaquel commented 1 week ago

2430 cleans up matplotlib space plotting. It would be great if the resulting cleaner API also works for altair space plotting.

quaquel commented 6 days ago

Some quick updates of what needs doing:

  1. rename make_space_altair to something like make_altair_space_component
  2. add make_altair_plot_component
  3. Add support for all spaces. This means including the hexgrid and network transformation of the x and y coordinates.
  4. Have a generic get_agent_data method
  5. The current code does all visual encoding in a "matplotlib" style by adding "color" and "size" explicitly to the long-form data frame that is the basis of any Altair plot. This seems to be at odds with the philosophy behind Altair which cleanly separates the data to be visualized from the visual encoding given to this data. So, in my view, we should pass a dataframe with the relevant attributes to altair and handle 'marker', 'size', and 'color' explicitly via encoding.
  6. Create the altair plot only once and only update the underlying data frame, See also #2255 and e.g., this open altair issue. I have been able to make the discussed work arround work. It is not yet the fully streaming of data, but worth exploring.