【问题标题】:Plotly adds slash after annotationPlotly 在注释后添加斜杠
【发布时间】:2021-06-17 18:37:40
【问题描述】:

我正在尝试在情节中向甘特图添加注释。但奇怪的是,在下一行的注释文本中添加了一个斜线。我确信我的注释中的文本字段是正确的并且不包含斜线。

数据:

rect = [{'Task': 'Task 1', 'Start': datetime.datetime(2021, 5, 5, 14, 4, 47, 398000), 'Finish': datetime.datetime(2021, 5, 5, 14, 4, 47, 482000), 'duration': '00:00.084'},
        {'Task': 'Task 2', 'Start': datetime.datetime(2021, 5, 5, 14, 4, 47, 545000), 'Finish': datetime.datetime(2021, 5, 5, 14, 4, 47, 579000), 'duration': '00:00.034'},
        {'Task': 'Task 3', 'Start': datetime.datetime(2021, 5, 5, 14, 4, 47, 583000), 'Finish': datetime.datetime(2021, 5, 5, 14, 5, 0, 980000), 'duration': '00:13.397'}]

注释:

annots = [{'x': datetime.datetime(2021, 5, 5, 14, 4, 47, 398000), 'y': 125.5, 'text': '8', 'font': {'color': 'black'}},
          {'x': datetime.datetime(2021, 5, 5, 14, 4, 47, 545000), 'y': 123.5, 'text': '3', 'font': {'color': 'black'}},
          {'x': datetime.datetime(2021, 5, 5, 14, 4, 47, 583000), 'y': 120.5, 'text': '9', 'font': {'color': 'black'}}]

代码:

rect = px.timeline(rect, x_start="Start", x_end="Finish", y="Task", hover_data=hover_data1, hover_name=hover_name)
rect.update_traces(marker=dict(line=dict(width=1, color='black')))
rect.update_xaxes(tickformat="%H:%M:%S.%L", tickmode='linear', dtick='120000')
rect.update_yaxes(showgrid=True, autorange=False, categoryorder='array', categoryarray=labels[::-1], range=[-1, len(labels)+.5])
rect.update_layout(title=title, showlegend=False, height=2800, width=2000, annotations=annots)

图表:

斜线出现在下一行。

谢谢:)

【问题讨论】:

    标签: python python-3.x plotly plotly-python gantt-chart


    【解决方案1】:

    Plotly 注释默认显示箭头 - 这可以在文档 here 中看到。要关闭此功能,请将以下行添加到代码末尾(添加注释后):

    rect.update_annotations(showarrow=False)
    

    【讨论】:

      猜你喜欢
      • 2014-09-10
      • 2012-03-25
      • 2017-12-12
      • 1970-01-01
      • 1970-01-01
      • 2015-04-18
      • 1970-01-01
      • 1970-01-01
      • 2018-06-29
      相关资源
      最近更新 更多