回答編集履歴
1
Update
answer
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
`matplotlib.colors.from_levels_and_colors` を使って `level` から color map を作成します。
|
1
|
+
`matplotlib.colors.from_levels_and_colors` を使って `level` から color map を作成します。`legend` は `scatter.legend_elements()` を明示的に指定することで表示されるようになります。
|
2
2
|
```python
|
3
3
|
from sklearn.cluster import DBSCAN
|
4
4
|
from sklearn.datasets import make_blobs
|
@@ -14,7 +14,7 @@
|
|
14
14
|
min_samples = [2, 3, 5]
|
15
15
|
epses = [1.0, 1.5, 2.0, 3.0]
|
16
16
|
|
17
|
-
levels = np.arange(
|
17
|
+
levels = np.arange(y.min()-1, y.max()+2)
|
18
18
|
colors = ["red", "blue", "green", "yellow"]
|
19
19
|
cmap, norm = matplotlib.colors.from_levels_and_colors(levels, colors)
|
20
20
|
|