我有一个数字信号图。我试图在我正在录制的过程的某些“阶段”进行遮蔽。我试过阅读文档并没有找到以下问题的直接答案。
1)First和formost:你能在填充区域添加hovertext吗?当光标在“绿色”区域上方时,我希望光标框说“阶段0”。以下是我尝试完成此操作的代码:
trace_stage0=go.Scatter(
x = [points['A'][0], points['B'][0]],
y = [1,1],
mode = 'line',
line = dict(width=0.2, color='rgb(0, 190, 0)'),
fill = 'tozeroy',
hoveron = "fills",
hovertext = "Stage 0",
showlegend = False)
for i in range(Num_Channels):
fig.append_trace(trace0[i],i+1,1)
fig.append_trace(trace_stage0,i+1,1)
2)我怎样才能摆脱每条线的终点?对我来说,他们分散了我试图描绘的信息。我试过mode ='none',但这显然剥夺了我控制填充颜色的能力。
3)有没有办法调整填充的不透明度?我想让它更轻一些。感谢
答案 0 :(得分:0)
感谢community.plot.ly中的'empet',这里是最终工作的代码。基本上,需要为阴影部分制作单独的情节。
#### Plot ploints for the text ####
trace_stages=dict(type='scatter',
x= stages_x,
y=[0.5, 0.5, 0.5, 0.5, 0.5, 0.5,
0.5, 0.5, 0.5, 0.5, 0.5],
mode='markers',
text=['stage 0', 'stage 1', 'stage 2', 'stage 3', 'stage 4', 'stage 5',
'stage 6', 'stage 7', 'stage 8','stage 9', 'stage 10'],
hoverinfo='text',
marker=dict(size=[0]),
showlegend = False
)
#### Plot for the shading ####
trace_stage0=go.Scatter(
x = [points['A'][0], points['B'][0]],
y = [1,1],
mode = 'markers+lines',
line = dict(width=0), # Setting width = 0 = no lines
marker=dict(size=[0,0]), # Setting size = [0,0] = no dots
fill = 'tozeroy',
fillcolor = 'rgba(190,0,0,.15)', # The '.15' sets opaqueness
hoverinfo = "none",
showlegend = False)
制作一些长代码,但它有效。