Python realtime plotting

后端 未结 4 1618
感动是毒
感动是毒 2020-12-09 13:42

I acquire some data in two arrays: one for the time, and one for the value. When I reach 1000 points, I trigger a signal and plot these points (x=time, y=value).

I n

4条回答
  •  伪装坚强ぢ
    2020-12-09 14:13

    To be totally interactive, you could use Bokeh for this. Concretely you could use an update function that is called every X ms and stream the new data.

    Here there is a fragment I use:

    def update():
         candle_data.stream(new_data, 300)   
    
    plot = figure(x_axis_type='datetime',x_range=(start_day, final_day), width=1500, height=900, title='Live Chart', sizing_mode='scale_both')
    plot.segment(x0='time', y0='highest', x1='time', y1='lowest', color='black', source=candle_data)
    plot.vbar(x='time', width = 0.5*60*60*50 ,bottom='open', top='close',fill_color='color', line_color='black', source = candle_data) 
    doc.add_root(column([plot]))
    doc.add_periodic_callback(update, 20000)
    doc.title = "Candle Data Live Rates"
    

提交回复
热议问题