質問編集履歴

1

コードの

2021/04/04 14:49

投稿

nbm140
nbm140

スコア0

test CHANGED
File without changes
test CHANGED
@@ -56,7 +56,7 @@
56
56
 
57
57
  ### コード
58
58
 
59
- import numpy as np
59
+ ```import numpy as np
60
60
 
61
61
  import pandas as pd
62
62
 
@@ -136,8 +136,12 @@
136
136
 
137
137
  img = cv2.imread('test.png')
138
138
 
139
+ ax1 = fig.add_subplot(1,1,2) #これでエラーが出る
140
+
139
141
  plt.show()
140
142
 
143
+
144
+
141
145
 
142
146
 
143
147
  def onMouseMotion(event):
@@ -150,7 +154,7 @@
150
154
 
151
155
 
152
156
 
153
- fig.canvas.mpl_connect('motion_notify_event', onMouseMotion)
157
+ fig.canvas.mpl_connect('motion_notify_event', onMouseMotion)
154
158
 
155
159
  plt.show()
156
160
 
@@ -166,6 +170,8 @@
166
170
 
167
171
  visualize3DData (X)
168
172
 
173
+ ```
174
+
169
175
 
170
176
 
171
177
 
@@ -177,3 +183,61 @@
177
183
  Python 3.7
178
184
 
179
185
  Jupyter Notebookで描画しています。
186
+
187
+
188
+
189
+ ### エラー内容
190
+
191
+ ax1 = fig.add_subplot(1,1,2)を追加した際に以下のエラーがマウスイベント発生時に表示されます。
192
+
193
+
194
+
195
+ Exception in Tkinter callback
196
+
197
+ Traceback (most recent call last):
198
+
199
+ File "C:\Users\user\anaconda3\lib\tkinter\__init__.py", line 1892, in __call__
200
+
201
+ return self.func(*args)
202
+
203
+ File "C:\Users\user\anaconda3\lib\site-packages\matplotlib\backends\_backend_tk.py", line 272, in motion_notify_event
204
+
205
+ FigureCanvasBase.motion_notify_event(self, x, y, guiEvent=event)
206
+
207
+ File "C:\Users\user\anaconda3\lib\site-packages\matplotlib\backend_bases.py", line 1903, in motion_notify_event
208
+
209
+ self.callbacks.process(s, event)
210
+
211
+ File "C:\Users\user\anaconda3\lib\site-packages\matplotlib\cbook\__init__.py", line 229, in process
212
+
213
+ self.exception_handler(exc)
214
+
215
+ File "C:\Users\user\anaconda3\lib\site-packages\matplotlib\cbook\__init__.py", line 81, in _exception_printer
216
+
217
+ raise exc
218
+
219
+ File "C:\Users\user\anaconda3\lib\site-packages\matplotlib\cbook\__init__.py", line 224, in process
220
+
221
+ func(*args, **kwargs)
222
+
223
+ File "<ipython-input-1-848925ac800b>", line 48, in onMouseMotion
224
+
225
+ Print_Pic (X, closestIndex)
226
+
227
+ File "<ipython-input-1-848925ac800b>", line 41, in Print_Pic
228
+
229
+ ax1 = fig.add_subplot(1,1,2) #これでエラーが出る
230
+
231
+ File "C:\Users\user\anaconda3\lib\site-packages\matplotlib\figure.py", line 1402, in add_subplot
232
+
233
+ ax = subplot_class_factory(projection_class)(self, *args, **kwargs)
234
+
235
+ File "C:\Users\user\anaconda3\lib\site-packages\matplotlib\axes\_subplots.py", line 39, in __init__
236
+
237
+ self._subplotspec = SubplotSpec._from_subplot_args(fig, args)
238
+
239
+ File "C:\Users\user\anaconda3\lib\site-packages\matplotlib\gridspec.py", line 689, in _from_subplot_args
240
+
241
+ raise ValueError(
242
+
243
+ ValueError: num must be 1 <= num <= 1, not 2