import numpy as np
import physt
%matplotlib inline
histogram = physt.h1(None, "fixed_width", bin_width=0.1, adaptive=True)
histogram
Histogram1D(bins=(0,), total=0, dtype=int64)
# Big chunk of data
data1 = np.random.normal(0, 1, 10000000)
histogram.fill_n(data1)
histogram
Histogram1D(bins=(106,), total=10000000, dtype=int64)
histogram.plot()
<matplotlib.axes._subplots.AxesSubplot at 0x7f5527d8e9b0>
Store the histogram:
histogram.to_json(path="./histogram.json");
del histogram
Turn off the machine, go for lunch, return home later...
Read the histogram:
histogram = physt.io.load_json(path="./histogram.json")
histogram
Histogram1D(bins=(106,), total=10000000, dtype=int64)
histogram.plot()
<matplotlib.axes._subplots.AxesSubplot at 0x7f5527b47748>
The same one ;-)
Continue filling:
# Another big chunk of data
data1 = np.random.normal(3, 2, 10000000)
histogram.fill_n(data1)
histogram
Histogram1D(bins=(212,), total=20000000, dtype=int64)
histogram.plot()
<matplotlib.axes._subplots.AxesSubplot at 0x7f552799d320>