我正在使用sns.jointplot绘制一些数据,我希望散点图中的数据保持为点,而旁边的直方图则是kde图。我尝试过使用kind='kde'参数,但这会改变内部的数据,使其不再像散点图中的点。我搜索了一段时间,却找不到方法。
下面是我的情节代码:
plota = sns.jointplot( data = Hub_all_data, y = "Within module degree", x= "Participation coefficient", s=100, joint_kws=({'color':'green'}), marginal_kws=({'color': 'green'}))
plota.ax_joint.axvline(x=np.quantile(Pall,.25), color = "black", linestyle = "--")
plota.ax_joint.axvline(x=np.quantile(Pall,.75), color = "black", linestyle = "--")
plota.ax_joint.axhline(y=np.quantile(within_module_degree,.25), color = "black", linestyle = "--")
plota.ax_joint.axhline(y=np.quantile(within_module_degree,.75), color = "black", linestyle = "--")
plota.ax_marg_x.set_xlim(0, .6)
plota.ax_marg_y.set_ylim(-3, 2)
plota.set_axis_labels('P', 'Z', fontsize=16)

发布于 2022-04-19 23:57:28
您可以创建一个JointGrid,然后分别绘制中心图和边缘图:
import seaborn as sns
import numpy as np
iris = sns.load_dataset('iris')
g = sns.JointGrid(data=iris, x="sepal_length", y="petal_length")
g.plot_joint(sns.scatterplot, s=100, color='green')
g.plot_marginals(sns.kdeplot, color='green', fill=True)
for q in np.quantile(iris['sepal_length'], [0.25, 0.75]):
for ax in (g.ax_joint, g.ax_marg_x):
ax.axvline(q, color="black", linestyle="--")
for q in np.quantile(iris['petal_length'], [0.25, 0.75]):
for ax in (g.ax_joint, g.ax_marg_y):
ax.axhline(q, color="black", linestyle="--")

https://stackoverflow.com/questions/71932243
复制相似问题