是否有使用Plotly制作QQ图的标准有效方法?
我想测试数据的正常/对数正态拟合。
答案 0 :(得分:1)
好的,这就是我现在的状况:
假设我们从一个分布中随机抽取500张,我们认为该分布可能是对数正态分布:
X_lognorm = np.random.lognormal(mean=0.0, sigma=1.7, size=500)
绘图
进口
import numpy as np
from scipy import stats
import plotly.graph_objs as go
from plotly.offline import init_notebook_mode, iplot
init_notebook_mode(connected=True)
情节奔跑
qq = stats.probplot(X_lognorm, dist='lognorm', sparams=(1))
x = np.array([qq[0][0][0],qq[0][0][-1]])
pts = go.Scatter(x=qq[0][0],
y=qq[0][1],
mode = 'markers',
showlegend=False
)
line = go.Scatter(x=x,
y=qq[1][1] + qq[1][0]*x,
showlegend=False,
mode='lines'
)
data = [pts, line]
layout = dict(xaxis = dict(zeroline = False,
linewidth = 1,
mirror = True),
yaxis = dict(zeroline = False,
linewidth = 1,
mirror = True),
)
fig = dict(data=data, layout=layout)
iplot(fig, show_link=False)