gpt4 book ai didi

seaborn fiddle 情节,我该如何设置标签?

转载 作者:行者123 更新时间:2023-12-02 06:30:36 26 4
gpt4 key购买 nike

我正在将向量列表绘制为一系列 fiddle 图。我会使用 pandas 数据框,但列表的长度不等。

这有效: python
g = sns.violinplot (data=res, cut=0, inner='box')

其中 'res' 是一个列表列表(每个都是浮点向量),其中每个向量都应该变成 fiddle 。是的。

但 x 轴只是标记为“0,1,2...”。添加参数 'names=[0,1,2...]' 会被忽略。

最佳答案

您可以使用 .set_xticklabels() 方法:

ax = sns.violinplot(data=res, cut=0, inner='box')
ax.set_xticklabels(['a','b','c'...])

例子:

import numpy as np, seaborn as sns

res = [i for i in (np.random.randn(3, 25))]
ax = sns.violinplot(data=res, cut=0, inner='box')
ax.set_xticklabels(['a','b','c'])

结果:

enter image description here

关于seaborn fiddle 情节,我该如何设置标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38746470/

26 4 0