Search code examples
plotlycustomizationlinechartfigure

How to create a curve plot (soft line chart) using Plotly python


I'm looking to build a line chart similar to the below one but I can't find a way to make the line "soft";

I tried to find a similar chart in Plotly but I didn't find it

enter image description here

I tried to find a similar chart in Plotly docs but I didn't find it;

There is a way to reproduce this chart using Plotly Express or graph_objects?

Thank you in advance,

Regards, Leonardo


Solution

  • I think you can use a spline to achieve what you want by passing the argument line_shape='spline' to go.Figure (described briefly in the interpolation with line plots section in the plotly documentation)

    For example:

    import numpy as np
    import plotly.graph_objects as go
    
    x = np.array([10, 20, 30, 40, 50])
    y = np.array([10, 30, 20, 50, 70])
    
    fig = go.Figure(go.Scatter(x=x, y=y, line_shape='spline'))
    fig.show()
    

    enter image description here