Histogram filled in real time from a stream of data
Code: "realtime_stream.py". Programming language: Python
DMelt Version 1. Last modified: 07/28/2017. License: Pro
https://datamelt.org/code/cache/realtime_stream_414.py
To run this script using the DMelt IDE,
copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.
from java.awt import Color
from java.util import Random
from java.lang import Thread
from jhplot import HPlot,H1D
import time
c1 = HPlot("Canvas",600,400)
c1.setGTitle("Histogram from stream of data (in real time)")
c1.visible(1)
c1.setLegend(0)
#c1.setAutoRange()
c1.setRange(-3,3,0,30)
h1 = H1D("Gaussian numbers every 0.5 sec",20, -2.0, 2.0)
h1.setFill(1)
h1.setErrX(0)
h1.setErrY(1)
h1.setFillColorTransparency(0.7)
h1.setFillColor(Color.blue)
h1.setColor(Color.blue)
h1.setPenWidthErr(2)
rand = Random()
for i in range(100):
h1.fill(rand.nextGaussian())
time.sleep(0.1)
c1.draw(h1)
c1.drawStatBox(h1)
time.sleep(0.5)
#c1.clearData()
You see the box below because you did not login.