joferkington / mpldatacursor

Interactive "data cursors" (a.k.a. annotation pop-ups) for matplotlib
MIT License
194 stars 47 forks source link

IndexError for filled contour plots (contourf) #78

Open wilywampa opened 7 years ago

wilywampa commented 7 years ago

When I try to select any point on the contour plot generated with the code below, I get the traceback below.

import matplotlib.pyplot as plt
import mpldatacursor
from mpl_toolkits.mplot3d import axes3d
X, Y, Z = axes3d.get_test_data(0.05)
cs = plt.contourf(X, Y, Z)
cursor = mpldatacursor.datacursor(cs)
plt.show()
Traceback (most recent call last):
  File "/Users/jniehus/Documents/dev/py3.6env/lib/python3.6/site-packages/matplotlib/backends/backend_qt5.py", line 286, in mouseDoubleClickEvent
    guiEvent=event)
  File "/Users/jniehus/Documents/dev/py3.6env/lib/python3.6/site-packages/matplotlib/backend_bases.py", line 1909, in button_press_event
    self.callbacks.process(s, mouseevent)
  File "/Users/jniehus/Documents/dev/py3.6env/lib/python3.6/site-packages/matplotlib/cbook.py", line 549, in process
    proxy(*args, **kwargs)
  File "/Users/jniehus/Documents/dev/py3.6env/lib/python3.6/site-packages/matplotlib/cbook.py", line 416, in __call__
    return mtd(*args, **kwargs)
  File "/Users/jniehus/.ipython/mpldatacursor/datacursor.py", line 708, in _select
    self(new_event)
  File "/Users/jniehus/.ipython/mpldatacursor/datacursor.py", line 235, in __call__
    self._show_annotation_box(event)
  File "/Users/jniehus/.ipython/mpldatacursor/datacursor.py", line 275, in _show_annotation_box
    self.update(event, annotation)
  File "/Users/jniehus/.ipython/mpldatacursor/datacursor.py", line 559, in update
    info = self.event_info(event)
  File "/Users/jniehus/.ipython/mpldatacursor/datacursor.py", line 308, in event_info
    props.update(func(event))
  File "/Users/jniehus/.ipython/mpldatacursor/pick_info.py", line 226, in scatter_props
    s = sizes[ind]
IndexError: index 0 is out of bounds for axis 0 with size 0
dmcnns commented 7 years ago

according to mpldatacursor manual unfortunately it seems that mpldatacursor can operate only on contour (line contour plot)