-
Notifications
You must be signed in to change notification settings - Fork 0
/
draw_with_grid.py
61 lines (54 loc) · 1.43 KB
/
draw_with_grid.py
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
from matplotlib import pyplot as plt
from matplotlib import colors
# In this script, you can save or draw your own grid by writing 1 and 0 !
smile = [
[0,0,0,1,1,1,1,0,0,0],
[0,0,1,0,0,0,0,1,0,0],
[0,1,0,0,0,0,0,0,1,0],
[1,0,0,1,0,0,1,0,0,1],
[1,0,0,1,0,0,1,0,0,1],
[1,0,0,0,0,0,0,0,0,1],
[1,0,0,1,0,0,1,0,0,1],
[0,1,0,0,1,1,0,0,1,0],
[0,0,1,0,0,0,0,1,0,0],
[0,0,0,1,1,1,1,0,0,0]
]
# Plot the data
# Here you can chose the colours to use in the image
colours_grid = ["white", "black"]
Cmap = colors.ListedColormap(colours_grid)
# Show the image
plt.figure(figsize=(20, 20))
plt.imshow(smile, cmap=Cmap)
#plt.axis('off')
plt.xticks(color='w')
plt.yticks(color='w')
plt.savefig("media/smile.png", format="png", dpi=300)
plt.show()
plt.close()
# This is a different draw as an example.
GRID = [
[0,1,1,1,1,1,1,1,1,0],
[1,1,0,0,0,0,0,0,1,1],
[1,0,0,0,0,0,0,0,0,1],
[1,0,0,0,1,1,0,0,0,1],
[1,0,0,1,0,0,1,0,0,1],
[1,0,0,1,0,0,1,0,0,1],
[1,0,0,0,1,1,0,0,0,1],
[1,0,0,0,0,0,0,0,0,1],
[1,1,0,0,0,0,0,0,1,1],
[0,1,1,1,1,1,1,1,1,0]
]
# Plot the data
# Here you can chose the colours to use in the image
colours_grid = ["white", "black"]
Cmap = colors.ListedColormap(colours_grid)
# Show the image
plt.figure(figsize=(20, 20))
plt.imshow(GRID, cmap=Cmap)
#plt.axis('off')
plt.xticks(color='w')
plt.yticks(color='w')
plt.savefig("media/flower.png", format="png", dpi=300)
plt.show()
plt.close()