回答編集履歴

2

修正

2020/06/14 09:48

投稿

tiitoi
tiitoi

スコア21956

test CHANGED
@@ -30,13 +30,23 @@
30
30
 
31
31
  ```python
32
32
 
33
- xs = np.arange(5)
33
+ import matplotlib.pyplot as plt
34
34
 
35
- ys = xs * 0.5
35
+ import numpy as np
36
36
 
37
- colors = ["r", "g", "b", "y"] # 4つの区間があるので4色
37
+ from matplotlib.collections import LineCollection
38
+
39
+
40
+
41
+ xs = [0, 1, 2, 3, 4]
42
+
43
+ ys = [0, 4, 3, 5, 7]
38
44
 
39
45
  lines = [[(x1, y1), (x2, y2)] for x1, y1, x2, y2 in zip(xs, ys, xs[1:], ys[1:])]
46
+
47
+ print(len(lines))
48
+
49
+ colors = ["r", "g", "b", "y"]
40
50
 
41
51
  lc = LineCollection(lines, colors=colors)
42
52
 
@@ -48,6 +58,8 @@
48
58
 
49
59
  ax.autoscale()
50
60
 
61
+ plt.show()
62
+
51
63
  ```
52
64
 
53
65
 

1

修正

2020/06/14 09:48

投稿

tiitoi
tiitoi

スコア21956

test CHANGED
@@ -1,6 +1,6 @@
1
- [LineCollection](https://matplotlib.org/3.2.1/api/collections_api.html#matplotlib.collections.LineCollection) は複数の線分をまとめたオブジェクトで、コンストラクタの第一引数 segments には、線分の一覧を [line1, line2, ...] とリストで指定します。
1
+ [LineCollection](https://matplotlib.org/3.2.1/api/collections_api.html#matplotlib.collections.LineCollection) は複数の線分をまとめたオブジェクトで、コンストラクタの第一引数 segments には、線分の一覧をリスト [line1, line2, ...] で指定します。
2
2
 
3
- 各 line は [(x1, y1), (x2, y2), ...] というその線分を構成する点の一覧になります。
3
+ 各 line は [(x1, y1), (x2, y2), ...] とその線分を構成する点の一覧になります。
4
4
 
5
5
 
6
6