Vindaar / ggplotnim

A port of ggplot2 for Nim
https://vindaar.github.io/ggplotnim
MIT License
175 stars 15 forks source link

`geom_bar` with `stat="identity"` and `position="stack"` broken if some fields missing #141

Open Vindaar opened 2 years ago

Vindaar commented 2 years ago

When using geom_bar with already computed statistics and stacking them based on some additional fill column (different groups by color), the generation of the plot can fail if not every group is present in each "stack" (has a value for each label of the fill column).

This is because in filledIdentityGeom (called due to stat = "identity") we do not call addZeroKeys as we do in filledCountGeom: https://github.com/Vindaar/ggplotnim/blob/master/src/ggplotnim/postprocess_scales.nim#L813

Possibly the fix is as simple as adding such a call to the "stack" logic here: https://github.com/Vindaar/ggplotnim/blob/master/src/ggplotnim/postprocess_scales.nim#L467