回答編集履歴
1
edit
test
CHANGED
@@ -1 +1,47 @@
|
|
1
1
|
plt.ylim((20,34))
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
---
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
```python
|
10
|
+
|
11
|
+
import matplotlib.pyplot as plt
|
12
|
+
|
13
|
+
import numpy as np
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
def samplemat(dims, shift=0):
|
18
|
+
|
19
|
+
"""Make a matrix with all zeros and increasing elements on the diagonal"""
|
20
|
+
|
21
|
+
aa = np.zeros(dims)
|
22
|
+
|
23
|
+
for i in range(min(dims)):
|
24
|
+
|
25
|
+
aa[i, i] = i
|
26
|
+
|
27
|
+
aa = np.vstack((np.zeros((shift, aa.shape[-1])), aa))
|
28
|
+
|
29
|
+
return aa
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
shift = 20
|
34
|
+
|
35
|
+
size = (15, 35)
|
36
|
+
|
37
|
+
# Display matrix
|
38
|
+
|
39
|
+
fig, ax = plt.subplots(dpi=200)
|
40
|
+
|
41
|
+
ax.matshow(samplemat(size, shift=shift-1))
|
42
|
+
|
43
|
+
ax.set_ylim((size[0]+shift-1.5,shift-0.5))
|
44
|
+
|
45
|
+
plt.show()
|
46
|
+
|
47
|
+
```
|