Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QQ-plot using Plotly in Python

Tags:

python

plotly

Is there a standard, effective way of producing a QQ-Plot using Plotly?

I would be interested in testing the normal/log-normal fit of my data.

like image 635
Sandu Ursu Avatar asked Jun 16 '26 17:06

Sandu Ursu


1 Answers

Alright, here is how I think the state of affairs is now [2020 edit]:

Say we have 500 random draws from a distribution which we think might be the lognormal distribution:

X_lognorm = np.random.lognormal(mean=0.0, sigma=1.7, size=500)

Plotting

Imports

import numpy as np
from scipy import stats
import plotly.graph_objects as go

Run plotly

qq = stats.probplot(X_lognorm, dist='lognorm', sparams=(1))
x = np.array([qq[0][0][0], qq[0][0][-1]])

fig = go.Figure()
fig.add_scatter(x=qq[0][0], y=qq[0][1], mode='markers')
fig.add_scatter(x=x, y=qq[1][1] + qq[1][0]*x, mode='lines')
fig.layout.update(showlegend=False)
fig.show()

enter image description here

like image 74
Sandu Ursu Avatar answered Jun 19 '26 08:06

Sandu Ursu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!