我试图从字典中的项目做一个散点图,需要使用seaborn进行比较。
对于每只动物,所列值需要在图中以碱基对重复数[1000, 2000, 3000]
进行比较。
x y
1000 53
2000 69
3000 0
import seaborn as sns
dict_1={'cat': [53, 69, 0], 'cheetah': [65, 52, 28]}
dict_2={'cat': [40, 39, 10], 'cheetah': [35, 62, 88]}
sns.set_theme()
sns.relplot(
data=dict_1,
x="organism", y="CpG sites")
技术说明:第一个字典是原始序列,第二个字典是具有相同ACGT含量的随机化序列,需要在图中比较列出的值作为重复的CG量。在原始序列中,对于前1000bp,CG重复53次,在随机化序列中,对于Cat,CG重复40次,然后在2000bp中,它在原始序列中重复69次,而对于随机化的一个,它重复39次,等等。
例如:而不是字典中列出的'tip' (x)
,'CG value'
,每1000个碱基对而不是'total_bill' (y)
。
1条答案
按热度按时间up9lanfz1#
pandas.DataFrame
中,然后使用组织数据的其他详细信息更新df
。dictionaries
中的值长度不等(如注解中所示),则使用Creating dataframe from a dictionary where entries have different lengths。dict
创建一个DataFrame,如链接的答案所示,然后再次使用pd.concat
合并每个DataFrame。*在
python 3.11.2
、pandas 2.0.0
、seaborn 0.12.2
中测试scatter
bar
df
前.melt
df.head()
后.melt
df.tail()
后.melt
注意事项
df