Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import matplotlib.pyplot as plt
- from matplotlib.widgets import TextBox
- import random
- fig, ax = plt.subplots(2,2,sharey=True)
- plt.subplots_adjust(bottom=0.2)
- n = 500
- x = [random.random() for i in range(n)]
- ax[0,0].hist(x,20)
- def submit(text):
- try:
- n = int(text)
- if n <= 0:
- raise ValueError
- except ValueError:
- return
- x = [random.random() for i in range(n)]
- ax[0,0].clear()
- ax[0,0].hist(x,20)
- plt.draw()
- axbox = plt.axes([0.1, 0.05, 0.8, 0.075])
- text_box = TextBox(axbox, 'Длина', initial=str(n))
- text_box.on_submit(submit)
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement