質問編集履歴

1

コード修正

2018/06/17 06:07

投稿

shougi
shougi

score0

test CHANGED
File without changes
test CHANGED
@@ -4,59 +4,65 @@
4
4
 
5
5
  ```python 3.x
6
6
 
7
- import matplotlib.cm as cm
7
+ import math
8
8
 
9
- import math
9
+ import numpy as np
10
10
 
11
11
  import matplotlib.pyplot as plt
12
12
 
13
- import numpy as np
13
+ import matplotlib.cm as cm
14
-
15
-
16
-
17
-
18
14
 
19
15
 
20
16
 
21
17
  # データ
22
18
 
23
- p2 =np.loadtxt('initial.csv',delimiter=',')
19
+ p2 =np.loadtxt('density_python.csv',delimiter=',')
24
20
 
25
- # 軸作成
26
21
 
27
- a,b = [],[]
28
22
 
29
- x = p2[0,:]
23
+ # yz軸作成
30
24
 
31
- y = p2[:,0]
25
+ yy,zz = [],[]
32
26
 
33
- x = y[1:]
27
+ y = p2[0,:]
34
28
 
35
- y = x[1:]
29
+ z = p2[:,0]
36
30
 
37
- for num in range(len(x)):
31
+ y = y[1:]
38
32
 
39
- a.append(y)
33
+ z = z[1:]
34
+
35
+
40
36
 
41
37
  for num in range(len(y)):
42
38
 
43
- b.append(z)
39
+ yy.append(y)
44
40
 
45
- c = np.array(a)
41
+ for num in range(len(z)):
46
42
 
43
+ zz.append(z)
44
+
45
+ Y = np.array(yy)
46
+
47
- d = np.array(b).T
47
+ Z = np.array(zz).T
48
+
49
+
50
+
51
+ #データ2次元配列作成
48
52
 
49
53
  p2 = np.delete(p2,0,1)
50
54
 
51
55
  p2 = np.delete(p2,0,0)
52
56
 
57
+
58
+
53
59
  #グラフ
54
60
 
55
- plt.contourf(c,d,p2,1000)
61
+ plt.contourf(Y,Z,p2,1000)
56
62
 
57
- plt.xlabel('takasa')
63
+ plt.xlabel('Y')
58
64
 
59
- plt.ylabel('haba')
65
+ plt.ylabel('Z')
60
66
 
61
67
  plt.imshow(p2,cmap=cm.bwr)
62
68