-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Problem
Similar to the stacking issue fixed in #244, dodge and jitter position adjustments compute group indices from the full DataFrame without accounting for facet panels. Since facet columns are included in partition_by (via add_discrete_columns_to_partition_by), compute_group_indices sees composite groups across facet panels rather than the groups within each panel.
Dodge
compute_group_indices(&df, &layer.partition_by) in dodge.rs:161 creates composite keys from all partition_by columns including facet columns. With fill=["X","Y"] and facet=["F1","F2"], dodge computes n_groups=4 (X-F1, X-F2, Y-F1, Y-F2) instead of the correct n_groups=2 (X, Y) per panel. This makes bars too narrow and offsets incorrect.
Jitter
Same issue when dodge=true — compute_group_indices(&df, &layer.partition_by) at jitter.rs:487 inflates the group count, producing incorrect dodge offsets.
Root cause
partition_by conflates two different kinds of columns:
- Grouping columns (fill, color) — used by dodge/jitter to determine
n_groups - Panel columns (facet1, facet2) — should reset computations per panel, not inflate group count
Related
- Position stacking is computed globally instead of per-facet-panel #244 — original stacking issue
- fix: compute position stacking per-facet-panel instead of globally #245 — stacking fix (reads facet columns from
spec.facetfor stacking groups)