'Plotting python code in browser during runtime

my overall problem is that I have code that I can't change that outputs values during the runtime of the program and I want to plot these values. It's also important that my main code calls the plot function which then displays the code and not the other way around. The main goal is that I can inspect the code on another device in the same WLAN. I wasn't sure which is the best tool to use so for now I am trying my luck with mpld3. A simplified version of the main code is the following:

import numpy as np
import matplotlib.pyplot as plt

plt.axis([0, 10, 0, 1])

for i in range(10):
    y = np.random.random()
    plt.scatter(i, y)
    plt.pause(0.05)

plt.show()

Now I thought I could add mpld3, which would show the plotting during runtime in the browser, by just replacing plt.show() with mpld3.show(). This however only shows the finished plot which is not what I wanted. Another problem is that I want to change the standard browser IP in which mpld3.show() gets shown to the IP of my computer, such that I can access the website via an apache server. Any recommendation's how I can solve my problem or do you know other tools which are better suited for my task?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source