gpt4 book ai didi

python - Seaborn:在条形图顶部叠加线图

转载 作者:行者123 更新时间:2023-12-01 03:54:53 31 4
gpt4 key购买 nike

这是我的数据框 -

    easy_donor  length  count   freq
0 Donor 1 NS 0 15637 0.000188
1 Donor 1 NS 1 144539 0.001737
2 Donor 1 NS 2 129792 0.001560
3 Donor 1 NS 3 143610 0.001726
4 Donor 1 NS 4 189110 0.002273
5 Donor 1 NS 5 474718 0.005706
6 Donor 1 NS 6 741730 0.008916
7 Donor 1 NS 7 908024 0.010915
8 Donor 1 NS 8 1892080 0.022744
9 Donor 1 NS 9 3107487 0.037355
10 Donor 1 NS 10 3789310 0.045551
11 Donor 1 NS 11 6321035 0.075984
12 Donor 1 NS 12 7469065 0.089784
13 Donor 1 NS 13 8493704 0.102101
14 Donor 1 NS 14 9633218 0.115799
15 Donor 1 NS 15 9008967 0.108295
16 Donor 1 NS 16 7682835 0.092354
17 Donor 1 NS 17 6669647 0.080175
18 Donor 1 NS 18 5199193 0.062499
19 Donor 1 NS 19 3809540 0.045794

我是这样绘制的。

import seaborn as sns
g = sns.factorplot(y='freq',
x='length',
data=collection_lengths,
col='easy_donor',
hue='easy_donor',
kind='bar')
g.set(xticks=range(2,31,3),xticklabels=range(2,31,3))
g.set_titles("")
g.set_axis_labels("HCDR3 Length","Frequency")
g.set_xticklabels(rotation=30)

enter image description here

是否可以在像这样的因子图中将连接线覆盖在条形图上?

编辑-

我所说的叠加是指绘制如下线图:

enter image description here

在实际的条形图之上(当然我会删除点并只保留线条)。

最佳答案

您可能会发现 this previous question有用,它指向 this seaborn tutorial.

我认为这个片段可以帮助你大部分的工作,

g = sns.FacetGrid(collection_lengths, col="easy_donor", hue='easy_donor')
g = g.map(sns.barplot, 'length', 'freq')
g = g.map(sns.pointplot, 'length', 'freq')
g.set(xticks=range(2,31,3),xticklabels=range(2,31,3))
g.set_axis_labels("HCDR3 Length","Frequency")
g.set_xticklabels(rotation=30)

关于python - Seaborn:在条形图顶部叠加线图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37648266/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com