I’d like to change the color of the line to red when the data is below 0 and green when it’s above it. So far I have the following line chart, for some reason, the lines are not connecting, is there a way to connect them?
traces.append({'x': df_req[df_req['sentiment'] < 0].dates,
'y': df_req[df_req['sentiment'] < 0].sentiment,
'name':tic, 'line':{'color':'green'}})
traces.append({'x': df_req[df_req['sentiment'] >= 0].dates,
'y': df_req[df_req['sentiment'] >= 0].sentiment,
'name':tic, 'line':{'color':'red'}})
fig = {
'data': traces,
'layout': {'title':', '.join(stock_ticker)+' Twitter Sentiment Index'}
}