1

我一直在使用joypy来绘制所谓的ridgeline/joy plots。我想将我的数据框平均分成几个部分,并递归地将它们中的每一个作为欢乐图并将它们完全添加以方便可视化。如果不这样做,我只会得到一个很难查看的很长的情节。我曾尝试在 for 循环中使用subplots并创建一个新的,但没有成功:(joypy.joyplot

import joypy
import mplcursors
from matplotlib import cm
import matplotlib.pyplot as plt

data = pd.DataFrame(np.random.rand(180,7), columns=list('ABCDEFG'))

x_range = list(range(len(data)))
fig, axes = joypy.joyplot(data, kind="values", x_range=x_range, colormap=cm.Set2,
                         figsize=(100,10))
axes[-1].set_xticks(x_range);
mplcursors.cursor(hover=True)

fig.savefig('joyplot.png', bbox_inches='tight')

我试过的:

import joypy
from matplotlib import cm
import matplotlib.pyplot as plt

f, a = plt.subplots(2, 1)
data = pd.DataFrame(np.random.rand(180,7), columns=list('ABCDEFG'))

for c, i in enumerate(range(0, len(data), 50)):
    x_range = list(range(i, i+50, 1))
    fig, axes = joypy.joyplot(data[i:i+50], kind="values", x_range=x_range, colormap=cm.Set2,
                             figsize=(100,10),
                             title="Emotion evolution over an interview")
    # I don't know what to do here so the current fig can be added as subplot..
    a[c].set_xticks(x_range);

fig.show()

另外,有谁知道如何使绘图具有交互性,因为当我的鼠标悬停在绘图上时,它的 y 轴值就会出现。mplcursors似乎不起作用。任何帮助表示赞赏!谢谢。

4

0 回答 0