Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def draw_plots(P, m, n, x, y, sample):
- def draw_plot(plot, x, values1, values2):
- x_plot = plt.subplot(111)
- x_plot.bar([x_i - 0.2 for x_i in x], values1, width=0.2, color='green', fill=True)
- x_plot.bar(x, values2, width=0.2, color='red', fill=True)
- Px = [sum(P_j) for P_j in P]
- Py = [sum([P[i][j] for i in range(m)]) for j in range(n)]
- Px_sample = [0] * m
- Py_sample = [0] * n
- x_sample = sorted([z[0] for z in sample])
- for i in range(m):
- Px_sample[i] = x_sample.count(x[i]) / len(x_sample)
- y_sample = sorted([z[1] for z in sample])
- for i in range(n):
- Py_sample[i] = y_sample.count(y[i]) / len(y_sample)
- plt.figure(1)
- draw_plot(plt, x, Px, Px_sample)
- plt.figure(2)
- draw_plot(plt, y, Py, Py_sample)
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement