本文介绍了Seaborn:条形图顶部的叠加线图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的数据框 -
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)
是否可以在像这样的因子图中将连接线覆盖在条形图上?
Is it possible to overlay the connecting line over the bar graph in a factorplot like this?
编辑 -
我所说的叠加是指有这样的线图:
What I mean by overlay is to have the line plot like this:
在实际条形图的顶部(当然,我会删除点并只有线).
On top of the actual barchart (of course I would remove the points and just have the line).
推荐答案
您可能会发现 上一个问题 有用,它指向这个seaborn教程.
You might find this previous question useful which points to this seaborn tutorial.
我认为这个片段会让你受益匪浅,
I think this snippet will get you most of the way,
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)
这篇关于Seaborn:条形图顶部的叠加线图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!