How to limit the size of the x section i a plotly waterfall plot?

Viewed 21

I used Python and ploty to make a waterfall plot but I can't find a way to limit the x-axis size on the final graph.

Is there a way to do so and still see the xaxis text? enter image description here

def waterfall_chart_roadtransport(actual, impacts_dico, objective, title, save = None):
    x_stage_1 = ["2021"]
    x_stage_2 = ["emissions"]
    measure = ["absolute"]
    y = [actual]
    for name, reduction in impacts_dico.items():
        x_stage_1.append("actions deployment")
        x_stage_2.append(name)
        y.append(reduction)
        measure.append("relative")
    x_stage_1.append("2025")
    x_stage_2.append("objective")
    x = [x_stage_1, x_stage_2]
    measure.append("absolute")
    y.append(objective)
    
    fig = go.Figure(go.Waterfall(
        x=x,
        measure=measure,
        y=y, base=0,
        decreasing={"marker": {"color": "Green", "line": {"color": "darkgreen", "width": 2}}},
        increasing={"marker": {"color": "Teal"}},
        totals={"marker": {"color": "deep sky blue", "line": {"color": "blue", "width": 3}}}
    ))
    fig.update_layout(title=title, waterfallgap=0.3)
    if save is not None:
        fig.write_html(save)

I tried to look in the documentation but nothing seemed to conviced me on the results.

0 Answers
Related