Quantcast
Channel: 🎛️ Dash - Plotly Community Forum
Viewing all articles
Browse latest Browse all 6271

Adding regression line and confidence interval to a scatter plot

$
0
0

@jonny-sexton wrote:

Hi all,

I am currently working on a Data Visualization project:

Is there any built-in function that enables me to automatically plot Regression lines and confidence intervals to this plot, or would I have to compute this manually from the scatter plot data and then plot this to the same graph? Checking the documentation I couldn’t find anything that supports this.

For reference, here is the code I am using for one of the plots:

dcc.Graph(
    id='km/h-speedcoefficient',
    figure={
        'data': [
            dict(
                x=df[df['SpeedCoefficient'] == i]['SpeedCoefficient'],
                y=df[df['SpeedCoefficient'] == i]['Km/h'],
                text=df[df['SpeedCoefficient'] == i]['Subproject'],
                mode='markers',
                opacity=0.7,
                marker={
                    'size': 15,
                    'line': {'width': 0.5, 'color': 'white'},
                    'color': df[df['SpeedCoefficient'] == i]['SpeedCoefficient'],
                    'cmin': min(df['SpeedCoefficient']),
                    'cmax': max(df['SpeedCoefficient']),
                    'colorscale': [[0.0, '#01cdfe'], [1.0, '#ff71ce']],#"Bluered",
                    'autocolorscale': False,
                    'showscale': True
                },
                name=i
            ) for i in df.SpeedCoefficient.unique()
        ],
        'layout': dict(
            title={'text': 'Km/h per SpeedCoefficient (0.1, 0.5, 1.0)'},
            xaxis={'type': 'lin', 'title': 'Speed Coefficient', 'color': 'white'},
            yaxis={'title': 'Km/h', 'color': 'white'},
            margin={'l': 40, 'b': 40, 't': 100, 'r': 10},
            legend={'x': 0, 'y': 1},
            showlegend=False,
            hovermode='closest',
            font={'color': 'white'},
            paper_bgcolor='#303030',
            plot_bgcolor='#424242'
        )
    }
)

Any help would be greatly appreciated, many thanks in advance!

Jonny

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 6271

Trending Articles