回答編集履歴

4

コード追加

2020/12/14 13:26

投稿

jbpb0
jbpb0

スコア7653

test CHANGED
@@ -8,35 +8,41 @@
8
8
 
9
9
 
10
10
 
11
+ 【追記】pandasデータフレームからnumpy配列への変換を追加
12
+
11
13
  ```python
12
-
13
- # 架空のデータ
14
14
 
15
15
  import numpy as np
16
16
 
17
- x1 = range(24)
17
+ import matplotlib.pyplot as plt
18
18
 
19
- y1 = np.random.rand(24)
20
19
 
21
- x2 = range(24)
22
20
 
23
- y2 = np.random.rand(24)
21
+ mcTrendAllnp = mcTrendAll.to_numpy()
24
22
 
25
- x3 = range(24)
26
23
 
24
+
25
+ xy1 = mcTrendAllnp[:, [0, 1]]
26
+
27
+ xy1 = xy1[~np.isnan(xy1).any(axis=1), :]
28
+
29
+
30
+
27
- y3 = np.random.rand(24)
31
+ xy2 = mcTrendAllnp[:, [0, 2]]
32
+
33
+ xy2 = xy2[~np.isnan(xy2).any(axis=1), :]
34
+
35
+
36
+
37
+ xy3 = mcTrendAllnp[:, [0, 3]]
38
+
39
+ xy3 = xy3[~np.isnan(xy3).any(axis=1), :]
28
40
 
29
41
 
30
42
 
31
43
 
32
44
 
33
45
  num = 12 # 強調したい数字
34
-
35
-
36
-
37
- import numpy as np
38
-
39
- import matplotlib.pyplot as plt
40
46
 
41
47
 
42
48
 
@@ -52,13 +58,13 @@
52
58
 
53
59
  ax.axvline(num, c='yellow', lw=0.5) # vertical lines
54
60
 
55
- ax.scatter(x1, y1, c='r', zorder=100)
61
+ ax.scatter(xy1[:, 0], xy1[:, 1], c='r', zorder=100)
56
62
 
57
- ax.scatter(x2, y2, c='g', zorder=100)
63
+ ax.scatter(xy2[:, 0], xy2[:, 1], c ='b', marker='^', zorder=100)
58
64
 
59
- ax.scatter(x3, y3, c='b', zorder=100)
65
+ ax.scatter(xy3[:, 0], xy3[:, 1], c ='g', marker='s', zorder=100)
60
66
 
61
- ax.grid()
67
+ ax.grid(color='lightgray', linestyle=':')
62
68
 
63
69
  ax.set_axisbelow(True)
64
70
 

3

コード追加

2020/12/14 13:26

投稿

jbpb0
jbpb0

スコア7653

test CHANGED
@@ -14,9 +14,17 @@
14
14
 
15
15
  import numpy as np
16
16
 
17
- x = range(24)
17
+ x1 = range(24)
18
18
 
19
- y = np.random.rand(24)
19
+ y1 = np.random.rand(24)
20
+
21
+ x2 = range(24)
22
+
23
+ y2 = np.random.rand(24)
24
+
25
+ x3 = range(24)
26
+
27
+ y3 = np.random.rand(24)
20
28
 
21
29
 
22
30
 
@@ -36,15 +44,19 @@
36
44
 
37
45
  ax.set_xticks(np.append(np.arange(0, 21, 5), num))
38
46
 
39
- colors = {str(num):'red'}
47
+ colors = {str(num):'yellow'}
40
48
 
41
49
  weights = {str(num):'bold'}
42
50
 
43
51
  sizes = {str(num):16}
44
52
 
45
- ax.axvline(num, c='red', lw=0.5) # vertical lines
53
+ ax.axvline(num, c='yellow', lw=0.5) # vertical lines
46
54
 
47
- ax.scatter(x, y, zorder=100)
55
+ ax.scatter(x1, y1, c='r', zorder=100)
56
+
57
+ ax.scatter(x2, y2, c='g', zorder=100)
58
+
59
+ ax.scatter(x3, y3, c='b', zorder=100)
48
60
 
49
61
  ax.grid()
50
62
 

2

コード修正

2020/12/14 12:27

投稿

jbpb0
jbpb0

スコア7653

test CHANGED
@@ -44,7 +44,7 @@
44
44
 
45
45
  ax.axvline(num, c='red', lw=0.5) # vertical lines
46
46
 
47
- ax.scatter(x, y)
47
+ ax.scatter(x, y, zorder=100)
48
48
 
49
49
  ax.grid()
50
50
 

1

コード追加

2020/12/14 11:38

投稿

jbpb0
jbpb0

スコア7653

test CHANGED
@@ -38,11 +38,17 @@
38
38
 
39
39
  colors = {str(num):'red'}
40
40
 
41
+ weights = {str(num):'bold'}
42
+
43
+ sizes = {str(num):16}
44
+
41
45
  ax.axvline(num, c='red', lw=0.5) # vertical lines
42
46
 
43
47
  ax.scatter(x, y)
44
48
 
45
49
  ax.grid()
50
+
51
+ ax.set_axisbelow(True)
46
52
 
47
53
  fig.canvas.draw()
48
54
 
@@ -52,6 +58,10 @@
52
58
 
53
59
  xtic.set_color(colors[xtic.get_text()])
54
60
 
61
+ xtic.set_weight(weights[xtic.get_text()])
62
+
63
+ xtic.set_fontsize(sizes[xtic.get_text()])
64
+
55
65
 
56
66
 
57
67
  plt.show()