1

我正在尝试在 python 中使用 seaborn 创建一个类似情节的小提琴和地毯情节(例如:情节类似的小提琴和地毯情节

我可以在小提琴图上叠加地毯图,这就是我迄今为止想出的:Seaborn 尝试。这是使用以下代码完成的:

import seaborn as sns
import matplotlib.pyplot as plt
sns.set(style="white")
sns.violinplot(data=[consp, intsp], scale='area', scale_hue=True, bw=.2, cut=1, linewidth=3)
sns.despine(left=False, bottom=True, top=True)
sns.rugplot(consp, height=0.05, axis='y', color='b')
sns.rugplot(intsp, height=0.05, axis='y', color='g')

但是,我想知道是否也可以在空间上将地毯图从不同的列中分离出来,并将它们覆盖在相应的列旁边,就像在 plotly 示例中一样?

通过为两个单独的 geom_rug 调用设置边,之前在 R 中为 ggplot2 解决了一个类似的问题,但似乎提供的解决方案不适用于 seaborn。(上一个问题解决了 R 中的类似问题:如何在空间上将地毯图从不同系列中分离出来

谢谢您的帮助。

4

0 回答 0