-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_points_images.py
More file actions
41 lines (28 loc) · 1.17 KB
/
generate_points_images.py
File metadata and controls
41 lines (28 loc) · 1.17 KB
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
36
37
38
39
40
41
import os
import numpy as np
import json
import matplotlib.pyplot as plt
with open("data/mnist/tsne0.json") as json_file:
data = json.load(json_file)
if not os.path.exists("demo/data/points"):
os.mkdir("demo/data/points")
rndperm = np.random.RandomState(seed=0).permutation(len(data['x']))
for n_points in range(500,70001,500):
img_name = "demo/data/points/points" + '_' + str(n_points) + '.png'
if not os.path.exists(img_name):
print('Creating:', img_name)
subset_x = [data['x'][i] for i in rndperm[0:n_points]]
subset_y = [data['y'][i] for i in rndperm[0:n_points]]
plt.figure(figsize=(7, 7))
ax = plt.subplot(111)
plt.axis('off')
# plt.scatter(data['x'], data['y'], s=7, alpha=1, lw=0, color='black')
plt.scatter(subset_x, subset_y, s=20, alpha=1, lw=0, color='black')
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
plt.xticks([])
plt.yticks([])
plt.setp(ax.get_xticklabels(), visible=False)
plt.setp(ax.get_yticklabels(), visible=False)
plt.savefig(img_name)
plt.close()