Have boxplots fit a category regardless of the total number of traces

I have the following Plotly plot right now. But as you can see, the boxplots are squished width-wise and after a lot of googling it seems that it is an intended behaviour from Plotly which “reserves” space for every category the total amount of boxplots in the plot (i hope that was clear).

I have the following Python code to format the data in a way so that I can easily read it in JS.

plot_data = plot_data.sort_index()

for index in plot_data.index:
    report_date, project_name = index.split("|")
    cleaned_data = plot_data.loc[[index]].transpose().dropna().values.flatten().tolist()
    trace = {
        "x0": report_date,
        "y": sorted(cleaned_data),
        "name": project_name,
        "type": "box",
        "marker": {
            "line": {
                "outlierwidth": 2
        "boxpoints": 'suspectedoutliers',

return json.dumps(traces)

And then I draw the plot using the following with plot being the variable that I pass from the backend using Django.

var plot_data = JSON.parse("{{plot|escapejs}}");
var layout = {
    xaxis: {
        type: "category",
        title: "Date",
    showlegend: false,
    boxmode: "group",
    boxgroupgap: 0.1,
    boxgap: 0.1,
Plotly.newPlot("plot-div", plot_data, layout, {responsive: true});

Is there anyway to have the boxplots correctly fit in every category?