Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- #coding: utf8
- import numpy as np
- import matplotlib
- import matplotlib.pyplot as plt
- import matplotlib.pylab as pylab
- matplotlib.rcParams['backend'] = "TkAgg"
- matplotlib.style.use('bmh')
- params = {'axes.titlesize': 'small', 'axes.titleweight': 'normal',
- 'axes.labelsize': 'small', 'axes.labelweight': 'normal',
- 'axes.facecolor': '#ffffff',
- 'axes.grid': True,
- 'axes.grid.which': 'both',
- 'xtick.labelsize': 'x-small', 'ytick.labelsize': 'x-small',
- 'xtick.direction': 'out', 'ytick.direction': 'out',
- 'ytick.left': True, 'xtick.bottom': True,
- 'ytick.minor.left': True, 'xtick.minor.bottom': True,
- 'xtick.minor.visible': True, 'ytick.minor.visible': True,
- }
- pylab.rcParams.update(params)
- figure = plt.figure(figsize=(29.7/2.54, 21.0/2.54))
- ##001
- def foo(xs:np.ndarray) -> np.ndarray:
- return(3 - np.cos(xs))
- xs = np.linspace(0, 6*np.pi, num=250)
- ys = foo(xs - 3 * np.sin(xs))
- figure.add_subplot(3,1,1)
- ax = figure.gca(); ax.set_aspect('equal')
- ax.set_title('Циклоида')
- ax.set_xlabel('x'); ax.set_ylabel('y')
- ax.set_xlim(np.min(xs) - .1, np.max(xs) + .1); ax.set_ylim(np.min(ys) - .1, np.max(ys) + .1)
- ax.plot(xs, ys, '--', color=(.2,.85,0), alpha=.35, linewidth=1)
- ax.text(.1, np.max(ys), 'Вот такая моя функция',
- fontsize=11, fontweight='light', family='monospace',
- horizontalalignment='left', verticalalignment='top')
- ##002
- xs = np.random.normal(0, 1, 3000)
- ys = np.random.normal(3, 4, 3000)
- figure.add_subplot(3,1,2)
- ax = figure.gca()
- ax.set_title('Scatter')
- ax.set_xlabel('x'); ax.set_ylabel('y')
- ax.set_xlim(np.min(xs) - .1, np.max(xs) + .1); ax.set_ylim(np.min(ys) - .1, np.max(ys) + .1)
- ax.scatter(xs, ys, c=(.8,0,0), s=4, marker='<', alpha=.35)
- ##003
- data = np.random.normal(16, 2, 1000)
- figure.add_subplot(3,1,3)
- ax = figure.gca()
- ax.hist(data, bins=100, color=(1,0,0,.6))
- figure.show()
- figure.savefig('plot01.{:s}'.format('png'), format='png',
- facecolor='white', dpi=300, bbox_inches='tight')
- figure.clf(); del(figure)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement