Waffle charts were previously using one square per agent, which looked very cluttered. To fix this we needed a way of grouping agents into squares so that each square represents more than one agent.
I'm using a proportional representation algorithm usually used for election voting to allocate a large number of votes to a relatively smaller number of seats. This can be generalised to allocate a large number of agents to a relatively smaller number of squares.
The create_waffle_chart function now has an option to specify the total number of squares in the chart. If this is different from the total number of agents, it will use the proportional representation algorithm to allocate agents to the squares.
In this case I'm using 546 for the total number of squares for consistency with the EV chart (546 is the total number of EVs, so the EV chart doesn't use proportional representation (1 square = 1 EV)). I'm also manually setting the number of rows in both charts to avoid the irregular shape seen before (charts are now 21x26).
We still have the issue in the agent chart where the total number of agents is changing at each timepoint (albeit less visible now). Presumably this shouldn't be the case and suggests a problem with the data. This is something we will have to bring up with Yue.
Before
After
Close #80
Type of change
[x] New feature (non-breaking change which adds functionality)
[ ] Optimization (non-breaking, back-end change that speeds up the code)
[ ] Bug fix (non-breaking change which fixes an issue)
[ ] Breaking change (whatever its nature)
Key checklist
[x] All tests pass (python -m pytest)
[x] Pre-commit hooks run successfully (pre-commit run --all-files)
Description
Waffle charts were previously using one square per agent, which looked very cluttered. To fix this we needed a way of grouping agents into squares so that each square represents more than one agent.
I'm using a proportional representation algorithm usually used for election voting to allocate a large number of votes to a relatively smaller number of seats. This can be generalised to allocate a large number of agents to a relatively smaller number of squares.
The
create_waffle_chart
function now has an option to specify the total number of squares in the chart. If this is different from the total number of agents, it will use the proportional representation algorithm to allocate agents to the squares.In this case I'm using 546 for the total number of squares for consistency with the EV chart (546 is the total number of EVs, so the EV chart doesn't use proportional representation (1 square = 1 EV)). I'm also manually setting the number of rows in both charts to avoid the irregular shape seen before (charts are now 21x26).
We still have the issue in the agent chart where the total number of agents is changing at each timepoint (albeit less visible now). Presumably this shouldn't be the case and suggests a problem with the data. This is something we will have to bring up with Yue.
Before
After
Close #80
Type of change
Key checklist
python -m pytest
)pre-commit run --all-files
)