Я изо всех сил пытаюсь отобразить аномалии в потоке, отображая точки аномалии в другом цвете.Я использую заговор для потоковой передачи данных.В настоящее время все точки отображаются красным цветом.Может ли кто-нибудь взглянуть на мой код, исправить его или предоставить предложение.
def setColor(y):
if y in list(theOutliersDF_TP.index): return 'red'
else: return 'yellow'
username = plotly_user_config['plotly_username']
api_key = plotly_user_config['plotly_api_key']
stream_token = plotly_user_config['plotly_streaming_tokens'][0]
p = plotly.plotly.sign_in(username, api_key)
plotly.plotly.iplot([{'x': [], 'y': [], 'type': 'scatter', 'mode': 'lines+markers', 'line': dict(color='green'),
'marker': dict(color=list(map(setColor,anomalies))),
'stream': {'token': stream_token}
}], filename='Tiime-Series', fileopt='extend')
s = plotly.plotly.Stream(stream_token)
s.open()
i = 0
while True:
x_data_point = theOutliersDF_TP['index'].iloc[i]
y_data_point = theOutliersDF_TP['weight'].iloc[i]
i += 1
s.write({'x': x_data_point, 'y': y_data_point})
time.sleep(80. / 1000.)