我在 seaborn KDE 图和 plotly 图中绘制了我的数据的密度图。我得到了相同数据的两个不同结果。这背后的原因是什么?
sb.kdeplot(data['ra'], data['dec'],cmap="Blues", shade=True, shade_lowest=True,cbar=True)
我在等高线图中使用相同的数据
fig = px.density_contour(data, x="ra", y="dec")
fig.update_traces(
contours_showlabels = True,
contours_coloring="fill",
colorbar=dict(
title='Number Count',
titleside='right',
titlefont=dict(
size=14,
family='Arial, sans-serif')))
fig.update_xaxes(title_text='RA')
fig.update_yaxes(title_text='DEC')
fig.update_layout(
#yaxis=dict(range=[-1.75, 1.5]),
height = 800,
width =800,
bargap = 0,
#hovermode = 'closest',
title_text='DENSITY PLOT',
showlegend = True
)
fig.show()
正如我们所看到的,左下角的轮廓处于不同的位置。那么,哪一个会更准确,这背后的原因是什么?
- 我的第二个问题是,如果我想通过使用相同的等高线级别/颜色条来比较数据的 seaborn KDE 等高线图来比较两个数据集。怎么做?当我在一个图上一起绘制时,它只是在同一图中独立绘制等高线图的水平。因此,我无法比较它,因为一个数据集包含的数字比另一个数据集多。
这是示例代码
slice_value1=slice_red1
X1=data1['ra']
Y1=data1['dec']
Z1=data1['redshift']
X2=data2['ra']
Y2=data2['dec']
Z2=data2['redshift']
fig = plt.figure(figsize=(12,10))
ax = fig.add_subplot(111,label='1')
k2=sb.kdeplot(X2,Y2,cmap='Reds',shade=False, shade_lowest=True,gridsize=500, cbar=True,annot = True)
k1=sb.kdeplot(X1,Y1,cmap='Blues',shade=False, shade_lowest=True,gridsize=500, cbar=True,annot = True)
ax.scatter(X2,Y2,s=0.8,color='Red')
ax.scatter(X1,Y1,s=0.8,color='blue')
ax.set_xlabel('RA')
ax.set_ylabel('DEC')
ax.set_xlim(349.5,354.3)
ax.set_ylim(-2,1.5)