簡體   English   中英

在散景的右軸上繪圖

[英]Plotting on the right axis in Bokeh

我正在構建一個多類別箱線圖,但無法將箱線圖對齊到正確的 position 中。

我有我的基因 x 軸,由數據庫細分。 但是我的 plot 在基因中間繪制了所有內容。

我讓我的軸是這樣的:

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)

我嘗試 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")

這導致我的 plot 像這樣繪制: https://imgur.com/a/8Q8YC1N

如何讓 plot 位於正確的位置? 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

genedb是 DataFrame 中的列嗎? 未以正確的格式提供坐標。 您提供了一個2 元組的列表,但需要的是一個2 元組的列表 坐標列表應如下所示:

x=[(gene1, db1), (gene2, db2), ...])

可能zip(gene, db)會提供您想要的。

盡管如此,我還強烈建議在處理嵌套分類數據時使用顯式創建的ColumnDataSource 可能會出現一些固有的歧義,而自己構建 CDS 可以消除這些歧義。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM