我试图使用pandas列中的唯一值将x记号插入到图形中。我不断地更新数据,所以我想要的东西,可以处理这不需要我不断地更新手动轴。我在下面试过了,但出现了一个错误。
df = pd.DataFrame({
'Item' : [1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4],
'x' : [-8.0,-4.0,0.5,0.0,0.0,2.0,3.0,5.0,10.0,-2.0,4.0,8.0,7.5,1.0,0.0,-2.0,-2.0,-2.0,-6.5,2.5],
'y' : [0.0,1.0,-0.5,5.5,-0.5,0.0,1.0,0.0,-5.0,-2.0,-2.0,-7.0,-0.5,-1.5,-0.5,0.0,1.0,-0.0,5.0,3.5],
})
fig, ax = plt.subplots(figsize = (10,6))
sns.lineplot(data = df,
x = 'Item',
y = 'y',
ci = 68,
ax = ax
)
plt.xticks(np.arange(0, (df['Item'].unique()) + 1, 1))
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()