回答編集履歴
5
修正d
answer
CHANGED
@@ -28,8 +28,12 @@
|
|
28
28
|
## 追記
|
29
29
|
|
30
30
|
```python
|
31
|
+
import matplotlib.pyplot as plt
|
32
|
+
import numpy as np
|
31
33
|
from mpl_toolkits.axes_grid1 import ImageGrid
|
32
34
|
|
35
|
+
data = np.random.randint(0, 256, (20, 20))
|
36
|
+
|
33
37
|
fig = plt.figure(figsize=(10, 5))
|
34
38
|
|
35
39
|
grid = ImageGrid(
|
@@ -52,9 +56,9 @@
|
|
52
56
|
extent=[0, data.shape[0], 0, data.shape[1]],
|
53
57
|
origin="lower",
|
54
58
|
)
|
59
|
+
grid[0].set_xlabel("X")
|
55
|
-
|
60
|
+
grid[1].set_xlabel("X")
|
56
|
-
ax2.set_xlabel("X")
|
57
|
-
|
61
|
+
grid[0].set_ylabel("Y")
|
58
62
|
|
59
63
|
for ax in grid:
|
60
64
|
# 目盛りはここで設定
|
4
修正
answer
CHANGED
@@ -36,7 +36,7 @@
|
|
36
36
|
fig,
|
37
37
|
111,
|
38
38
|
nrows_ncols=(1, 2),
|
39
|
-
axes_pad=0.
|
39
|
+
axes_pad=0.2,
|
40
40
|
share_all=True,
|
41
41
|
cbar_location="right",
|
42
42
|
cbar_mode="single",
|
@@ -56,7 +56,8 @@
|
|
56
56
|
ax2.set_xlabel("X")
|
57
57
|
ax1.set_ylabel("Y")
|
58
58
|
|
59
|
-
for ax in
|
59
|
+
for ax in grid:
|
60
|
+
# 目盛りはここで設定
|
60
61
|
ax.set_xticks(np.arange(0, 21, 2))
|
61
62
|
ax.set_yticks(np.arange(0, 21, 2))
|
62
63
|
|
@@ -65,4 +66,4 @@
|
|
65
66
|
plt.show()
|
66
67
|
```
|
67
68
|
|
68
|
-

|
3
修正
answer
CHANGED
@@ -23,4 +23,46 @@
|
|
23
23
|
plt.show()
|
24
24
|
```
|
25
25
|
|
26
|
-

|
26
|
+

|
27
|
+
|
28
|
+
## 追記
|
29
|
+
|
30
|
+
```python
|
31
|
+
from mpl_toolkits.axes_grid1 import ImageGrid
|
32
|
+
|
33
|
+
fig = plt.figure(figsize=(10, 5))
|
34
|
+
|
35
|
+
grid = ImageGrid(
|
36
|
+
fig,
|
37
|
+
111,
|
38
|
+
nrows_ncols=(1, 2),
|
39
|
+
axes_pad=0.1,
|
40
|
+
share_all=True,
|
41
|
+
cbar_location="right",
|
42
|
+
cbar_mode="single",
|
43
|
+
)
|
44
|
+
|
45
|
+
im1 = grid[0].imshow(
|
46
|
+
data, cmap="plasma", extent=[0, data.shape[0], 0, data.shape[1]], origin="lower",
|
47
|
+
)
|
48
|
+
im2 = grid[1].imshow(
|
49
|
+
data,
|
50
|
+
cmap="plasma",
|
51
|
+
interpolation="bicubic",
|
52
|
+
extent=[0, data.shape[0], 0, data.shape[1]],
|
53
|
+
origin="lower",
|
54
|
+
)
|
55
|
+
ax1.set_xlabel("X")
|
56
|
+
ax2.set_xlabel("X")
|
57
|
+
ax1.set_ylabel("Y")
|
58
|
+
|
59
|
+
for ax in [grid[0], grid[1]]:
|
60
|
+
ax.set_xticks(np.arange(0, 21, 2))
|
61
|
+
ax.set_yticks(np.arange(0, 21, 2))
|
62
|
+
|
63
|
+
grid.cbar_axes[0].colorbar(im2)
|
64
|
+
|
65
|
+
plt.show()
|
66
|
+
```
|
67
|
+
|
68
|
+

|
2
修正
answer
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
divider = make_axes_locatable(ax2)
|
20
20
|
cax = divider.append_axes("right", size="5%", pad=0.05)
|
21
|
-
|
21
|
+
fig.colorbar(im2, cax=cax)
|
22
22
|
|
23
23
|
plt.show()
|
24
24
|
```
|
1
修正
answer
CHANGED
@@ -4,24 +4,23 @@
|
|
4
4
|
```python
|
5
5
|
import matplotlib.pyplot as plt
|
6
6
|
import numpy as np
|
7
|
+
from mpl_toolkits.axes_grid1 import make_axes_locatable
|
7
8
|
|
8
9
|
data = np.random.randint(0, 256, (20, 20))
|
9
10
|
|
10
|
-
fig,
|
11
|
+
fig, [ax1, ax2] = plt.subplots(figsize=(8, 4), ncols=2, sharey=True)
|
11
|
-
im1 = axes[0].imshow(data, cmap="plasma")
|
12
|
-
|
12
|
+
im1 = ax1.imshow(data, cmap="plasma", aspect="auto")
|
13
|
-
|
13
|
+
im2 = ax2.imshow(data, cmap="plasma", interpolation="bicubic", aspect="auto")
|
14
|
-
|
14
|
+
ax1.set_xlabel("X")
|
15
|
+
ax2.set_xlabel("X")
|
15
|
-
|
16
|
+
ax1.set_ylabel("Y")
|
17
|
+
fig.subplots_adjust(wspace=0.07)
|
16
18
|
|
17
|
-
|
19
|
+
divider = make_axes_locatable(ax2)
|
18
|
-
# add_axes([x軸の開始位置, y軸の開始位置, x軸の長さ(全体に対する比率), y軸の長さ(全体に対する比率)])
|
19
|
-
|
20
|
+
cax = divider.append_axes("right", size="5%", pad=0.05)
|
20
|
-
|
21
|
+
plt.colorbar(im2, cax=cax)
|
21
|
-
|
22
|
+
|
22
|
-
plt.subplots_adjust(right=0.85)
|
23
|
-
plt.subplots_adjust(wspace=0.15)
|
24
23
|
plt.show()
|
25
24
|
```
|
26
25
|
|
27
|
-

|