我正在尝试更改直方图和正态分布曲线,这是使用plotly中的create_distplot功能生成的。我找不到任何东西可以让我在这个图上添加更多的痕迹。是否有其他方法可以使用其他plotly功能获得相同的结果
GAIA = pd.read_csv(r'C:\Users\Admin\Desktop\New folder\6 SEM Python\WORK\Astrometry\DistancePM.csv')
df = pd.DataFrame(GAIA, columns = ['ra','dec','rest','b_rest','B_rest','pmra','pmra_error','pmdec','pmdec_error','PM'])
ra = df['ra'].tolist()
dec = df['dec'].tolist()
rest = df['rest'].tolist()
b_rest = df['b_rest'].tolist()
B_rest = df['B_rest'].tolist()
pmra = df['pmra'].tolist()
pmra_E = df['pmra_error'].tolist()
pmdec = df['pmdec'].tolist()
pmdec_E = df['pmdec_error'].tolist()
PM = df['PM'].tolist()
PM1 = []
c = 0
#Here we are onlly taking the range from tehabove contour plot where there is a
#clustering of data points x = [-4.5, 1.5] and y = [3, 1]
for i in range(len(PM)):
if (PM[i]<100 and pmra[i]>-4.5 and pmra[i]<1.5 and pmdec[i]>1 and pmdec[i]<3):
PM1.append(PM[i])
c+=1
group_labels = ['Proper Motion']
color = ['#636EFA', '#EF553B', '#00CC96', '#AB63FA', '#FFA15A', '#19D3F3', '#FF6692', '#B6E880', '#FF97FF', '#FECB52']
fig = ff.create_distplot(
[PM1],
group_labels,
bin_size = 0.05,
curve_type='normal',
colors = color
)
fig.update_layout(
title = 'Proper Motion Histogram + Gaussian distribution ',
xaxis = dict(
title='Proper Motion'
),
yaxis = dict(
title='Density'
),
template = 'plotly_dark',
showlegend = True
)
fig.show()
print(c)[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/lOBvY.png
您尚未指定如何显示添加的数据,因此我只能假设这就是您要查找的内容:
如果是这种情况,您可以使用
np.mean()
计算度量值,并使用以下公式将其添加到图中:下面是一个完整的代码片段,平均值+/-一个标准偏差:
相关问题 更多 >
编程相关推荐