-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
35 lines (26 loc) · 858 Bytes
/
Copy pathtest.py
File metadata and controls
35 lines (26 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
# Define numbers of generated data points and bins per axis.
N_numbers = 100000
N_bins = 20
# set random seed
np.random.seed(0)p = np.pi
# Generate 2D normally distributed numbers.
x, y = np.random.multivariate_normal(
mean=[0.0, 0.0], # mean
cov=[[1.0, 0.4],
[0.4, 0.25]], # covariance matrix
size=N_numbers
).T # transpose to get columns
# Construct 2D histogram from data using the 'plasma' colormap
plt.hist2d(x, y, bins=N_bins, normed=False, cmap='plasma')
# Plot a colorbar with label.
cb = plt.colorbar()
cb.set_label('Number of entries')
# Add title and labels to plot.
plt.title('Heatmap of 2D normally distributed data points')
plt.xlabel('x axis')
plt.ylabel('y axis')
# Show the plot.
plt.show()