I’m trying to establish a simple function that intakes a few variables and will display the function on the server and update in real time accordingly. Most of the trouble stems from calling the server itself as the bokeh plot refuses to show unless I manually type in “bokeh serve --show rttCall.py.” This is a problem as I need the program to autonomously set up the socket since I will be accessing the function from an external application, such as MATLAB.
Here is the Main Function with the Bokeh Plot Instruction:
rtt.py:
import os
from bokeh.io import output_file,show
from bokeh.driving import count
from bokeh.models import ColumnDataSource, HoverTool
from bokeh.plotting import curdoc, figure
from bokeh.client import push_session
import math
import timedef sinusoid(a,b,c,d):
t0=time.time()
source = ColumnDataSource({“x”: , “y”: })
sinPlot = figure(x_range=(1,10),plot_width=450)
sinPlot.line(“x”, “y”, source=source)@count() def update(t): t =(time.time()-t0)*3 test={'x':[t], 'y':[a*math.sin(b*t+c)+d]} source.stream(test) sinPlot.x_range.start=t-20 sinPlot.x_range.end=t doc = curdoc() doc.add_root(sinPlot) doc.add_periodic_callback(update,50) print("Function runs :) !") print(a,b,c,d)
#sinusoid(10,1,0,5)
This is how I intend to access this base function from either another python program or MATLAB through the pylib:
rttCall.py:
import rtt
import os
rtt.sinusoid(10,10,0,0)
os.system(‘cmd /k “cd C:\Users\zmaty\AppData\Local\Programs\Python\Python37\DLLs && bokeh serve --show rttCall.py”’)
However, the web page is opened but is completely blank, thus my implementation must be wrong.
Is there a different way to implement this Bokeh Server so that either the Main Function RTT.py is able to set up the server itself or have it running for any other application to call the function Sinusoid and load it directly?