我正在尝试使用“标记”作为plotly 5.4.0的线函数
import plotly.express as px
df_temp = df_temp[df_temp.date_str.isin(selected_dates)]
fig = px.line(df_temp, x='trialID', y='reaction_time', color='date_str', markers=True,
title=f'Graph2. Intervention status: {status}')
我收到错误:
TypeError: line() got an unexpected keyword argument 'markers'
我读到这是关于更新的,但我不认为是这样。有谁知道它可能是什么?
df_temp, selected_dates, status
import plotly.express as px
import pandas as pd
import numpy as np
df_temp = pd.DataFrame(
{
"date_str": np.repeat(pd.date_range("1-jan-2021", periods=10), 10).astype(str),
"trialID": np.tile(np.arange(10), 10),
"reaction_time": np.random.uniform(0, 2, 100),
}
)
selected_dates = pd.Series(df_temp["date_str"].unique()).sample(5).values
status = "my favorite status"
df_temp = df_temp[df_temp.date_str.isin(selected_dates)]
fig = px.line(
df_temp,
x="trialID",
y="reaction_time",
color="date_str",
markers=True,
title=f"Graph2. Intervention status: {status}",
)
fig
Plotly 的文档将其标记为有效参数:
markers(布尔值(默认 False)) – 如果为 True,则标记显示在行上。
对我来说升级plotly版本修复了它。您可以使用
import plotly
然后使用 plotly.__version__
检查绘图版本。 (实际上您可以对任何库执行此操作)。我似乎无法找到有关 API 规范何时引入的历史记录,但从上面的答案来看,它在 5.4 中有效,而对我来说,它在 5.1 中不起作用。