python - 类型错误 : __init__() got multiple values for argument 'marks'

标签 python plotly plotly-dash

我收到以下错误 TypeError: __init__() got multiple values for argument 'marks' 下面的代码,我不确定如何最好地修复它。我知道它指的是标记,但我不确定这需要如何更改? 提前致谢

app = dash.Dash(__name__)
app.title = "Performance"
dfsites = pd.read_csv("3msites.csv")

colors = {
    "background": "#011833", 
    "text": "#7FDBFF"
} #Dictionary of colors to use later

fig1 = px.scatter(dfsites, x='Spend',y='CPA', 
                size= 'Conversions', color='Campaign', hover_name='Site',
                log_x=True)

)
app.layout = html.Div(children=[
    html.Div([
        html.H4(children='Sites', style={"textAlign": "center"}),

        dcc.Graph(
            id='site-graph',
            figure=fig1),
        dcc.Slider(
            dfsites['Month'].min(),
            dfsites['Month'].max(),
            step=None,
            value=dfsites['Month'].min(),
            marks={str(Month) for Month in dfsites['Month'].unique()},
            id='Month-slider'
    )  
]),
])

@app.callback(
    Output('site-graph', 'figure'),
    Input('Month-slider', 'value'))
def update_figure(selected_Month):
    filtered_dfsites = dfsites[dfsites.Month == selected_Month]

    fig1.update_layout(transition_duration=500)
    
    return fig1

if __name__ == '__main__':
    app.run_server(debug=True)

回溯错误:

Traceback (most recent call last):
  File "/Users/~/Dash.py", line 94, in <module>
    dcc.Slider(
  File "/Users/~/opt/anaconda3/lib/python3.8/site-packages/dash/development/base_component.py", line 366, in wrapper
    return func(*args, **kwargs)
TypeError: __init__() got multiple values for argument 'marks'

最佳答案

我在使用 Dropdown 组件时遇到了类似的错误:

__init__() got multiple values for argument 'id'

就我而言,我必须更新破折号:

pip3 install dash --upgrade

此外,我必须像这样更新组件配置:

dcc.Dropdown(
   options=['New York City', 'Montreal', 'San Francisco'],
   value='Montreal'
)

(请参阅此处的组件引用文档:https://dash.plotly.com/dash-core-components)

关于python - 类型错误 : __init__() got multiple values for argument 'marks' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71121523/

相关文章:

r - Plotly with R ggplot 隐私

postgresql - 无法在 Dash 应用程序中根据 PostgreSQL 查询结果绘制图形

python - 如何为 Plotly Dash 回调函数编写测试用例?

python - 列出单独的值

python - kerasequential().predict(x_test) 只返回两个类的 1 列

python 数组创建语法 [for in range]

python - Mac上Python2.7导入tkinter

python - 绘图中重叠的色阶

r - 如何使用函数 ggplot() 和 plot_ly 增加 R 中轴标签和轴标题之间的空间?

python - 是否可以在 plotly 中反转子弹图?