簡體   English   中英

如何在plotly python中的add_shape上使add_traces中的文本可見

[英]How to make text visible in add_traces over the add_shape in plotly python

我有一個包含矩形和文本的圖。 我看到我在 add_traces 中的文本不可見。 但是當我嘗試在 add_shape() 中移除填充顏色時,我可以看到痕跡。 這是一個示例代碼:

for row in df.index:
    fig.add_shape(type="rect",x0=start, y0=1, x1=start+df[score][row], y1=1.5,line=dict(color='green',),fillcolor='green',)
    start=start+df['score'][row]+2
fig.add_trace(go.Scatter(x=np.cumsum(list(df['score']+2))-df['score'][0],y=[1.25]*df.shape[0],mode="text",textfont=dict(family="sans serif",size=10,color="yellow"),
    text=list(df['Exon_Number']), showlegend=False,textposition='top center',))

如何通過在矩形形狀上顯示痕跡來使文本可見?

提前謝謝了!

回答我自己的問題,希望它對將來的任何人有所幫助。

在 add_shape 函數中,我們可以使用 layer='below' 將圖層發回。 因此,文本痕跡將是可見的。

對於 df.index 中的行: fig.add_shape(type="rect",x0=start, y0=1, x1=start+df[score][row], y1=1.5,layer = 'below',line=dict (color='green',),fillcolor='green',) start=start+df['score'][row]+2 fig.add_trace(go.Scatter(x=np.cumsum(list(df[' score']+2))-df['score'][0],y=[1.25]*df.shape[0],mode="text",textfont=dict(family="sans serif",size= 10,color="yellow"), text=list(df['Exon_Number']), showlegend=False,textposition='top center',))

暫無
暫無

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

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