[英]Plotting on the right axis in Bokeh
I'm building a multi-categorial boxplot and I'm having trouble aligning the boxplots to be in the right position.我正在构建一个多类别箱线图,但无法将箱线图对齐到正确的 position 中。
I have my x axis of genes which is subdivided by databases.我有我的基因 x 轴,由数据库细分。 But my plot plots everything in the middle on gene.
但是我的 plot 在基因中间绘制了所有内容。
I make my axis like this:我让我的轴是这样的:
x = sorted(list(set([(gene, database) for gene in totaldf['gene'].to_list() for database in totaldf['db'].to_list()])))
p = figure(background_fill_color="#efefef", x_range=FactorRange(*x), width=1600, height=700)
and I try to plot my boxes like this:我尝试 plot 我的盒子是这样的:
p.vbar(x=(gene, db), width=0.7, bottom=q2[gene, db], top=q3[gene, db], fill_color="#ffffff", line_color="black")
p.vbar(x=(gene, db), width=0.7, bottom=q1[gene, db], top=q2[gene, db], fill_color="#ffffff", line_color="black")
This results in my plot plotting like this: https://imgur.com/a/8Q8YC1N这导致我的 plot 像这样绘制: https://imgur.com/a/8Q8YC1N
How do I get the plot to be in the right locations?如何让 plot 位于正确的位置? The dataframe looks like this:
dataframe 看起来像这样:
gene db mutations
0 IGHV1-3 G1K_CL2 6
1 IGHV1-58 G1K_CL2 2
2 IGHV1-58 G1K_CL2 3
3 IGHV1-8 G1K_CL2 2
4 IGHV3-16 G1K_CL2 3
.. ... ... ...
141 IGHV4-61 G1K_CL3 11
142 IGHV4-61 G1K_CL3 12
143 IGHV4-61 G1K_CL3 10
144 IGHV4-61 G1K_CL3 13
145 IGHV7-81 G1K_CL3 4
gene
and db
are the columns from the DataFrame? gene
和db
是 DataFrame 中的列吗? The coordinates are not being supplied in the correct format.未以正确的格式提供坐标。 You are supplying a 2-tuple of lists , but what is required is a list of 2-tuples .
您提供了一个2 元组的列表,但需要的是一个2 元组的列表。 The coordinate list should look like:
坐标列表应如下所示:
x=[(gene1, db1), (gene2, db2), ...])
Probably zip(gene, db)
will provide what you intend.可能
zip(gene, db)
会提供您想要的。
All that said, I also strongly advise to use explicitly created ColumnDataSource
when dealing with nested categorical data.尽管如此,我还强烈建议在处理嵌套分类数据时使用显式创建的
ColumnDataSource
。 There are some inherent ambiguities that can arise and constructing a CDS yourself eliminates those.可能会出现一些固有的歧义,而自己构建 CDS 可以消除这些歧义。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.