plotly.js icon indicating copy to clipboard operation
plotly.js copied to clipboard

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

Open amna-sib opened this issue 6 months ago • 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: https://github.com/plotly/plotly.js/issues/930

amna-sib avatar Aug 28 '25 06:08 amna-sib

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.

emilykl avatar Sep 15 '25 17:09 emilykl