我正在尝试在条形图上创建一条水平线,我可以这样做,使用散点图作为另一个轨迹。
但是,由于红线没有完全延伸,我尝试在go.Layout中使用Shapes参数,但它给了我以下错误:
Invalid value of type 'builtins.dict' received for the 'shapes' property of layout Received value: {'type': 'line', 'x0': 0, 'y0': 2, 'x1': 4, 'y1': 2, 'line': {'color': 'red', 'width': 4, 'dash': 'dashdot'}} The 'shapes' property is a tuple of instances of Shape that may be specified as: - A list or tuple of instances of plotly.graph_objs.layout.Shape - A list or tuple of dicts of string/value properties that will be passed to the Shape constructor
这是密码
bar_chart = [go.Bar(x=competitor_df.index,
y=competitor_df['competitor_cost'],
marker_color=colors,
marker_line_width=1.5,
marker_line_color='#505461',
textposition='outside',
texttemplate="$%{y}")]
layout = go.Layout(yaxis=dict(range=[0, competitor_df.max]),
xaxis=dict(range=[0, 4]),
shapes=dict(
type='line',
x0=0,
y0=2,
x1=4,
y1=2,
line=dict(color='red', width=4, dash='dashdot')))
fig = {'data':bar_chart, 'layout':layout}
非常感谢您的帮助
这在plotly分类数据中是一个问题。您需要对水平线使用绝对/纸张定位,例如
相关问题 更多 >
编程相关推荐