teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

エラー分を書き足しました

2017/11/24 06:15

投稿

ruuruusann24
ruuruusann24

スコア16

title CHANGED
File without changes
body CHANGED
@@ -1,8 +1,65 @@
1
1
  度々すみません
2
2
  これの最後のshow_volonoi_with_metrics(dist.euclidean)でエラーが出てしまいます。
3
3
  なにか良い方法はありますでしょうか
4
+ 以下エラーです
5
+ --------------------------------------------
6
+ RuntimeError Traceback (most recent call last)
7
+ <ipython-input-62-670a63d7ce7e> in <module>()
8
+ ----> 1 show_volonoi_with_metrics(dist.euclidean)
9
+
10
+ <ipython-input-61-e1fd4304de1a> in show_volonoi_with_metrics(metrics)
11
+ 15 xs = map(lambda p: p[0], cluster_points)
12
+ 16 ys = map(lambda p: p[1], cluster_points)
13
+ ---> 17 ax.scatter(xs, ys, color=cm.prism(i / float(len(c_means))), marker='.')
14
+ 18
15
+ 19 ax.scatter(map(lambda p: p[0], c_means), map(lambda p: p[1], c_means), color="g", marker='o')
16
+
17
+ ~/anaconda3/envs/styletrans/lib/python3.6/site-packages/matplotlib/__init__.py in inner(ax, *args, **kwargs)
18
+ 1708 warnings.warn(msg % (label_namer, func.__name__),
19
+ 1709 RuntimeWarning, stacklevel=2)
20
+ -> 1710 return func(ax, *args, **kwargs)
21
+ 1711 pre_doc = inner.__doc__
22
+ 1712 if pre_doc is None:
23
+
24
+ ~/anaconda3/envs/styletrans/lib/python3.6/site-packages/matplotlib/axes/_axes.py in scatter(self, x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, verts, edgecolors, **kwargs)
25
+ 4007 edgecolors = 'face'
26
+ 4008
27
+ -> 4009 self._process_unit_info(xdata=x, ydata=y, kwargs=kwargs)
28
+ 4010 x = self.convert_xunits(x)
29
+ 4011 y = self.convert_yunits(y)
30
+
31
+ ~/anaconda3/envs/styletrans/lib/python3.6/site-packages/matplotlib/axes/_base.py in _process_unit_info(self, xdata, ydata, kwargs)
32
+ 1967 # we only need to update if there is nothing set yet.
33
+ 1968 if not self.xaxis.have_units():
34
+ -> 1969 self.xaxis.update_units(xdata)
35
+ 1970
36
+ 1971 if ydata is not None:
37
+
38
+ ~/anaconda3/envs/styletrans/lib/python3.6/site-packages/matplotlib/axis.py in update_units(self, data)
39
+ 1430 """
40
+ 1431
41
+ -> 1432 converter = munits.registry.get_converter(data)
42
+ 1433 if converter is None:
43
+ 1434 return False
44
+
45
+ ~/anaconda3/envs/styletrans/lib/python3.6/site-packages/matplotlib/units.py in get_converter(self, x)
46
+ 160 if converter is None:
47
+ 161 try:
48
+ --> 162 thisx = safe_first_element(x)
49
+ 163 except (TypeError, StopIteration):
50
+ 164 pass
51
+
52
+ ~/anaconda3/envs/styletrans/lib/python3.6/site-packages/matplotlib/cbook/__init__.py in safe_first_element(obj)
53
+ 2310 except TypeError:
54
+ 2311 pass
55
+ -> 2312 raise RuntimeError("matplotlib does not support generators "
56
+ 2313 "as input")
57
+ 2314 return next(iter(obj))
58
+
4
59
  RuntimeError: matplotlib does not support generators as input
5
60
 
61
+ 以下コードです
62
+ --------------------------------------------
6
63
  import numpy as np
7
64
  import matplotlib.pyplot as plt
8
65
  import matplotlib.cm as cm