Static and real-time data Bokeh server

Hi all,

I am trying to create polar chart( or phasor diagram) in Bokeh and show real time phasor results.
I need to create circular axis that will remain unchanged, and then stream the realtime data on top of that.
Can you please guide me how to create static graph as the axis? If I put everything in update function it becomes very slow and buggy.

Hi,

You will get a much better response if you share code for what you've tried. Ideally, a complete script that someone can run and tinker with and return to you improved.

Thanks,

Bryan

···

On May 14, 2018, at 12:55, [email protected] wrote:

Hi all,

I am trying to create polar chart( or phasor diagram) in Bokeh and show real time phasor results.
I need to create circular axis that will remain unchanged, and then stream the realtime data on top of that.
Can you please guide me how to create static graph as the axis? If I put everything in update function it becomes very slow and buggy.

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/7733ec0b-7d4c-49e3-af47-18c19fdf8aa6%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Please see below the code that I am using. My Goal is to keep the “Circular Axis” created in # Create Circular Axis section as the background. Then stream live data on top of that.

import numpy as np

import pandas as pd

from bokeh.plotting import figure

from bokeh.io import curdoc

from bokeh.models import ColumnDataSource

width = 820

height = 820

inner_radius = 50

outer_radiuss = 400

start_angle=0

end_angle=0.5*np.pi

angles = np.linspace(0,350,36)

p = figure(plot_width=width, plot_height=height, title="",

x_axis_type=None, y_axis_type=None,

x_range=(-450, 450), y_range=(-450, 450),

min_border=0, outline_line_color=“black”,background_fill_color="#f0e1d2")

radii=np.linspace(inner_radius,outer_radiuss,10)

xr = (radii[-1]+10)*np.cos(np.array(np.deg2rad(angles)))

yr = (radii[-1]+5)*np.sin(np.array(np.deg2rad(angles)))

Create Circular Axis

p.circle(0,0,radius=radii, fill_color=None, line_color=“white”)

p.annular_wedge(0,0,0,outer_radiuss,angles,angles,start_angle_units=‘deg’,end_angle_units=‘deg’,line_color=‘gray’,line_dash=‘dotted’)

p.text(xr, yr, angles, 0, text_font_size=“8pt”, text_align=“center”, text_baseline=“middle”)

···

create columndatasource

source=ColumnDataSource(dict(m1=,ang1=,m2=,ang2=))

df=pd.read_csv(r’C:\Users\golesh\AnacondaProjects\phasor_data.csv’)

df[‘x’]=df[‘magnitude’]outer_radiussnp.cos(np.deg2rad(df[‘angle’]))

df[‘y’]=df[‘magnitude’]outer_radiussnp.sin(np.deg2rad(df[‘angle’]))

create live phasors streamed from CSV

p.annular_wedge(0,0,0,outer_radius=‘m1’,start_angle=‘ang1’,end_angle=‘ang1’,start_angle_units=‘deg’,end_angle_units=‘deg’,line_color=‘black’,source=source, level=‘overlay’)

p.annular_wedge(0,0,0,outer_radius=‘m2’,start_angle=‘ang2’,end_angle=‘ang2’,start_angle_units=‘deg’,end_angle_units=‘deg’,line_color=‘red’,source=source, level=‘overlay’)

counter=0

def update():

global counter

new_data=dict(m1=df[‘magnitude’][counter:counter+1]*outer_radiuss,ang1=df[‘angle’][counter:counter+1],

m2=df[‘magnitude’][counter+1:counter+2]*outer_radiuss,ang2=df[‘angle’][counter+1:counter+2])

print(new_data)

source.stream(new_data,rollover=1)

counter +=1

print(source.data)

if counter==20:

counter=0

print(counter)

for i in range(0,len(df[‘x’])):

df[‘x’][i]=df[‘x’][20]+3.14*(i)

curdoc().add_periodic_callback(update,100) #100 ms

curdoc().add_root§

On Monday, May 14, 2018 at 3:56:01 PM UTC-4, [email protected] wrote:

Hi all,

I am trying to create polar chart( or phasor diagram) in Bokeh and show real time phasor results.

I need to create circular axis that will remain unchanged, and then stream the realtime data on top of that.

Can you please guide me how to create static graph as the axis? If I put everything in update function it becomes very slow and buggy.