To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit 1d5a4029 authored by Henrik Menne's avatar Henrik Menne
Browse files

push merge

parent 6c293208
Pipeline #32824 passed with stages
in 3 minutes and 51 seconds
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
import matplotlib
matplotlib.use("TkAgg")
class UpdateDist(object):
def __init__(self, ax):
self.success = 0
self.line, = ax.plot([], [], 'ko')
self.x = 1
self.ax = ax
# Set up plot parameters
self.ax.set_xlim(0, 2)
self.ax.set_ylim(0, 100)
self.ax.grid(True)
# This vertical line represents the theoretical value, to
# which the plotted distribution should converge.
# self.ax.axvline(prob, linestyle='--', color='black')
def init(self):
# self.success = 0
self.line.set_data([], [])
return self.line,
def __call__(self, i):
# This way the plot can continuously run and we just keep
# watching new realizations of the process
if i == 0:
return self.init()
# Choose success based on exceed a threshold with a uniform pick
# if np.random.rand(1,) < self.prob:
# self.success += 1
y = i
self.line.set_data(self.x, y)
return self.line,
fig, ax = plt.subplots()
fig_1, ax_1 = plt.subplots()
ud = UpdateDist(ax)
ud_1 = UpdateDist(ax_1)
# p1.start()
anim_2 = FuncAnimation(fig_1,
ud_1,
frames=100,
interval=500,
init_func=ud_1.init,
blit=True)
anim = FuncAnimation(fig,
ud,
frames=100,
init_func=ud.init,
interval=1000,
blit=True)
plt.show()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment