我想在箱线图的顶部覆盖一个简单的散点图。当我分别绘制这两个图时,一切正常:
但当我尝试将它们组合起来时,几乎看起来散射图的x值都被2除:
我很确定这是因为箱线图将x轴值视为分类的(即使它们在我的数据帧中是浮动的),而散点图将它们视为连续的。但我不知道解决办法是什么。以下是我正在使用的代码:
sns.scatterplot(data=old_data, x="x-axis", y="y-axis", s=200, color="red", label="Old Data")
sns.boxplot(data=new_data, x="x-axis", y="y-axis", color="blue")
plt.plot([], [], label="New Data", color='blue') # this just adds the boxplot label to the legend
plt.legend()
附加问题:如果您知道如何更好地将箱线图标签添加到图例中,我很想听听
目前没有回答
相关问题 更多 >
编程相关推荐