回答編集履歴
7
修正
answer
CHANGED
@@ -3,14 +3,10 @@
|
|
3
3
|
a.set_ticklabels([])
|
4
4
|
a._axinfo['grid']['linewidth'] = 0
|
5
5
|
a._axinfo['tick']['linewidth'] = 0
|
6
|
-
|
7
|
-
for a in [ax.w_xaxis, ax.w_yaxis, ax.w_zaxis]:
|
8
|
-
a.line.set_linewidth(0)
|
9
|
-
a.set_pane_color((0., 0., 0., 0.))
|
10
|
-
#順にRGBA
|
11
6
|
```
|
12
7
|
|
8
|
+
上がエラーの原因です。
|
13
|
-
名前が `_` から始まっている属性、関数というのは外部に公開されていないものなので、バージョン変更で変わってしまった可能性がありますね。
|
9
|
+
名前が `_` から始まっている属性、関数というのは外部に公開されていない (ユーザーが使うことが想定されていない) ものなので、バージョン変更で変わってしまった可能性がありますね。
|
14
10
|
この処理は目盛りの軸を消す処理だと思いますが、`ax.set_axis_off()` で同じことができます。
|
15
11
|
|
16
12
|
## サンプルコード
|
6
修正
answer
CHANGED
@@ -28,7 +28,7 @@
|
|
28
28
|
|
29
29
|
|
30
30
|
def draw(event):
|
31
|
-
fig = plt.figure(figsize=(
|
31
|
+
fig = plt.figure(figsize=(4, 4))
|
32
32
|
|
33
33
|
ax = fig.gca(projection="3d", facecolor="k")
|
34
34
|
ax.set_xlim([-1.0, 1.0])
|
5
修正
answer
CHANGED
@@ -34,7 +34,7 @@
|
|
34
34
|
ax.set_xlim([-1.0, 1.0])
|
35
35
|
ax.set_ylim([-1.0, 1.0])
|
36
36
|
ax.set_zlim([-1.0, 1.0])
|
37
|
-
ax.set_axis_off()
|
37
|
+
ax.set_axis_off()
|
38
38
|
|
39
39
|
u, v = np.mgrid[0 : 2 * np.pi : 50j, 0 : np.pi : 25j]
|
40
40
|
x = np.cos(u) * np.sin(v)
|
@@ -43,7 +43,7 @@
|
|
43
43
|
|
44
44
|
# (50, 25, 3) の色の配列を作成する。
|
45
45
|
colors = np.zeros((50, 25, 3))
|
46
|
-
colors[:25] = np.random.rand(3)
|
46
|
+
colors[:25, :] = np.random.rand(3)
|
47
47
|
|
48
48
|
ax.plot_surface(x, y, z, facecolors=colors, shade=False)
|
49
49
|
|
4
修正
answer
CHANGED
@@ -34,7 +34,7 @@
|
|
34
34
|
ax.set_xlim([-1.0, 1.0])
|
35
35
|
ax.set_ylim([-1.0, 1.0])
|
36
36
|
ax.set_zlim([-1.0, 1.0])
|
37
|
-
ax.set_axis_off()
|
37
|
+
ax.set_axis_off() # 軸を消す
|
38
38
|
|
39
39
|
u, v = np.mgrid[0 : 2 * np.pi : 50j, 0 : np.pi : 25j]
|
40
40
|
x = np.cos(u) * np.sin(v)
|
@@ -43,7 +43,7 @@
|
|
43
43
|
|
44
44
|
# (50, 25, 3) の色の配列を作成する。
|
45
45
|
colors = np.zeros((50, 25, 3))
|
46
|
-
colors[:25
|
46
|
+
colors[:25] = np.random.rand(3) # 半分の色を変更する
|
47
47
|
|
48
48
|
ax.plot_surface(x, y, z, facecolors=colors, shade=False)
|
49
49
|
|
3
修正
answer
CHANGED
@@ -13,6 +13,8 @@
|
|
13
13
|
名前が `_` から始まっている属性、関数というのは外部に公開されていないものなので、バージョン変更で変わってしまった可能性がありますね。
|
14
14
|
この処理は目盛りの軸を消す処理だと思いますが、`ax.set_axis_off()` で同じことができます。
|
15
15
|
|
16
|
+
## サンプルコード
|
17
|
+
|
16
18
|
以下のコードで tkinter ありで動作しました。
|
17
19
|
|
18
20
|
```python
|
2
修正
answer
CHANGED
@@ -1,6 +1,20 @@
|
|
1
|
+
```
|
1
|
-
|
2
|
+
for a in [ax.xaxis, ax.yaxis, ax.zaxis]:
|
2
|
-
|
3
|
+
a.set_ticklabels([])
|
4
|
+
a._axinfo['grid']['linewidth'] = 0
|
5
|
+
a._axinfo['tick']['linewidth'] = 0
|
3
6
|
|
7
|
+
for a in [ax.w_xaxis, ax.w_yaxis, ax.w_zaxis]:
|
8
|
+
a.line.set_linewidth(0)
|
9
|
+
a.set_pane_color((0., 0., 0., 0.))
|
10
|
+
#順にRGBA
|
11
|
+
```
|
12
|
+
|
13
|
+
名前が `_` から始まっている属性、関数というのは外部に公開されていないものなので、バージョン変更で変わってしまった可能性がありますね。
|
14
|
+
この処理は目盛りの軸を消す処理だと思いますが、`ax.set_axis_off()` で同じことができます。
|
15
|
+
|
16
|
+
以下のコードで tkinter ありで動作しました。
|
17
|
+
|
4
18
|
```python
|
5
19
|
import numpy as np
|
6
20
|
from matplotlib import colors as mcolors
|
@@ -8,50 +22,41 @@
|
|
8
22
|
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2Tk
|
9
23
|
from matplotlib.figure import Figure
|
10
24
|
from mpl_toolkits.mplot3d import Axes3D
|
11
|
-
import
|
25
|
+
import tkinter
|
12
26
|
|
13
|
-
fig = plt.figure(figsize=(4, 4))
|
14
|
-
ax = fig.gca(projection="3d")
|
15
27
|
|
28
|
+
def draw(event):
|
16
|
-
|
29
|
+
fig = plt.figure(figsize=(6, 6))
|
17
|
-
ax.set_ylim([-1.0, 1.0])
|
18
|
-
ax.set_zlim([-1.0, 1.0])
|
19
30
|
|
20
|
-
for a in [ax.xaxis, ax.yaxis, ax.zaxis]:
|
21
|
-
a.set_ticklabels([])
|
22
|
-
a._axinfo["grid"]["linewidth"] = 0
|
23
|
-
|
31
|
+
ax = fig.gca(projection="3d", facecolor="k")
|
32
|
+
ax.set_xlim([-1.0, 1.0])
|
33
|
+
ax.set_ylim([-1.0, 1.0])
|
34
|
+
ax.set_zlim([-1.0, 1.0])
|
35
|
+
ax.set_axis_off()
|
24
36
|
|
25
|
-
|
37
|
+
u, v = np.mgrid[0 : 2 * np.pi : 50j, 0 : np.pi : 25j]
|
26
|
-
|
38
|
+
x = np.cos(u) * np.sin(v)
|
27
|
-
|
39
|
+
y = np.sin(u) * np.sin(v)
|
28
|
-
|
40
|
+
z = np.cos(v)
|
29
41
|
|
42
|
+
# (50, 25, 3) の色の配列を作成する。
|
30
|
-
|
43
|
+
colors = np.zeros((50, 25, 3))
|
44
|
+
colors[:25, :] = np.random.rand(3)
|
31
45
|
|
32
|
-
|
46
|
+
ax.plot_surface(x, y, z, facecolors=colors, shade=False)
|
33
47
|
|
34
|
-
x = np.cos(u) * np.sin(v)
|
35
|
-
|
48
|
+
azim = np.random.randint(-90, 270)
|
36
|
-
|
49
|
+
ax.view_init(elev=0, azim=azim)
|
37
50
|
|
38
|
-
|
51
|
+
canvas = FigureCanvasTkAgg(fig, master=root)
|
39
|
-
b = random.random()
|
40
|
-
|
52
|
+
canvas.get_tk_widget().place(x=0,y=0)
|
41
53
|
|
42
|
-
colors = np.zeros((50, 25, 3))
|
43
|
-
|
54
|
+
root = tkinter.Tk()
|
44
|
-
|
55
|
+
root.geometry("800x600")
|
45
|
-
colors[i][j][0] = a
|
46
|
-
colors[i][j][1] = b
|
47
|
-
colors[i][j][2] = c
|
48
56
|
|
49
|
-
|
57
|
+
button= tkinter.Button(root, text=u'ボタン',width=15)
|
58
|
+
button.bind("<Button-1>",draw)
|
59
|
+
button.place(x=300,y=450)
|
50
60
|
|
51
|
-
moon = random.randint(-90, 270)
|
52
|
-
|
53
|
-
|
54
|
-
ax.view_init(elev=0, azim=moon)
|
55
|
-
|
56
|
-
|
61
|
+
tkinter.mainloop()
|
57
62
|
```
|
1
修正
answer
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
以下のコードでこちらの環境では発生しませんでした。
|
1
|
+
tkinter 関連のコードを削除して以下のコードでこちらの環境ではエラーが発生しませんでした。
|
2
2
|
matplotlib のバージョン: 3.2.2
|
3
3
|
|
4
4
|
```python
|
@@ -52,4 +52,6 @@
|
|
52
52
|
|
53
53
|
|
54
54
|
ax.view_init(elev=0, azim=moon)
|
55
|
+
|
56
|
+
plt.show()
|
55
57
|
```
|