[英]Adding 500 circles in a plotly graph using add_shape function takes 45 seconds, how to reduce this?
[英]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.