plotly/plotly.js

Grouped bar chart leaves gaps when some traces have no values for an x-axis tick

amna-sib opened this issue · 1 comments

I’m trying to create a grouped bar chart with multiple traces (e.g., 5). For certain x-axis ticks, not all traces have values. When a trace has no value for a tick, Plotly currently leaves an empty space in the group, which creates unwanted gaps in the bars. Additionally, when the last trace is missing, the bars can look not centered, which makes the chart visually misleading.

Proposed behavior:
If only 4 traces out of 5 have data for a given x-axis tick, Plotly should render just 4 bars side by side without reserving space for the missing trace. This would make grouped bars more compact and visually accurate.

Note that this is the same problem as in this closed issue that was never resolved: #930

Hi @amna-sib , thank you for raising this. The current behavior of grouped bars (i.e. leaving a gap) is desirable in some cases, so we are unlikely to change the existing behavior; however we would welcome a PR adding a new barmode as described in #930.