ex-7: improve plots
This commit is contained in:
parent
7fd86ac64f
commit
2864d9e524
24
ex-7/plot.py
24
ex-7/plot.py
@ -7,8 +7,7 @@ def line(x, y, **args):
|
|||||||
'''line between two points x,y'''
|
'''line between two points x,y'''
|
||||||
plot([x[0], y[0]], [x[1], y[1]], **args)
|
plot([x[0], y[0]], [x[1], y[1]], **args)
|
||||||
|
|
||||||
plt.rcParams['font.size'] = 30
|
rcParams['font.size'] = 12
|
||||||
|
|
||||||
w = loadtxt(sys.stdin, max_rows=2)
|
w = loadtxt(sys.stdin, max_rows=2)
|
||||||
v = array([[0, -1], [1, 0]]) @ w
|
v = array([[0, -1], [1, 0]]) @ w
|
||||||
cut = float(input())
|
cut = float(input())
|
||||||
@ -19,17 +18,24 @@ signal, noise = data[:n].T, data[n:].T
|
|||||||
|
|
||||||
figure()
|
figure()
|
||||||
subplot(aspect='equal')
|
subplot(aspect='equal')
|
||||||
scatter(*signal, edgecolor='#51492d', c='#dbbb4a', label='signal')
|
scatter(*signal, edgecolor='xkcd:charcoal',
|
||||||
scatter(*noise, edgecolor='#512d3d', c='#d64d88', label='noise')
|
c='xkcd:dark yellow', label='signal')
|
||||||
line(-20*w, 20*w, c='xkcd:blue', label='projection')
|
scatter(*noise, edgecolor='xkcd:charcoal',
|
||||||
line(w-10*v, w+10*v, c='xkcd:red', label='cut')
|
c='xkcd:pale purple', label='noise')
|
||||||
|
line(-20*w, 20*w, c='xkcd:midnight blue', label='projection')
|
||||||
|
line(w-10*v, w+10*v, c='xkcd:scarlet', label='cut')
|
||||||
xlim(-1.5, 8)
|
xlim(-1.5, 8)
|
||||||
ylim(-1.5, 8)
|
ylim(-1.5, 8)
|
||||||
|
legend()
|
||||||
|
tight_layout()
|
||||||
|
|
||||||
figure()
|
figure()
|
||||||
sig_proj = np.dot(w, signal)
|
sig_proj = np.dot(w, signal)
|
||||||
noise_proj = np.dot(w, noise)
|
noise_proj = np.dot(w, noise)
|
||||||
hist(sig_proj, color='#dbbb4a')
|
hist(sig_proj, color='xkcd:dark yellow', label='signal')
|
||||||
hist(noise_proj, color='#d64d88')
|
hist(noise_proj, color='xkcd:pale purple', label='noise')
|
||||||
axvline(cut, c='r')
|
axvline(cut, c='xkcd:scarlet')
|
||||||
|
legend()
|
||||||
|
tight_layout()
|
||||||
|
|
||||||
show()
|
show()
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user