Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash after highlight x:[.. None ..], y:[.. float ..] data #101

Open
GVA-error opened this issue Nov 25, 2020 · 0 comments
Open

Crash after highlight x:[.. None ..], y:[.. float ..] data #101

GVA-error opened this issue Nov 25, 2020 · 0 comments

Comments

@GVA-error
Copy link

xData = [0, 1, None, 2, 3]
yData = [0, 1, 1.5, 2, 3]

The left side of the graph can be highlighted, but the right one cannot.

image

Source cod:

import sys

from PyQt5.QtWidgets import QApplication, QMainWindow

from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure
from mpldatacursor import HighlightingDataCursor


class MainWidget(QMainWindow):
    def __init__(self):
        QMainWindow.__init__(self)
        figure = Figure(figsize=(10, 5), dpi=85, linewidth=0.1)
        canvas = FigureCanvas(figure=figure)
        somePlot = figure.add_subplot(111)

        xData = [0, 1, None, 2, 3]
        yData = [0, 1, 1.5, 2, 3]
        someLinePlot = somePlot.plot(xData, yData, 'r.-', label='Value')
        myCursor = HighlightingDataCursor(someLinePlot, highlight_color='red', highlight_width=1, hover=True, \
                                             display='single', xytext=(15, 15), formatter=self.myFormater)
                                             # "single"|"multiple"|"one-per-axes" - the result is the same
                                             
                                             
        canvas.draw()
        self.setCentralWidget(canvas)
        
    def myFormater(self, x=None, y=None, z=None, s=None, label=None, **kwargs):
        output = []
        if x == None or y == None:
            return u"\n"
        output.append(u'{key}: {val:0.3g}'.format(key=label, val=x))
        output.append(u'{key}: {val:0.3g}'.format(key=self.tr('Depth'), val=y))
        #output.append(u'(' + label + ')')
        return u"\n".join(output)


if __name__ == "__main__":
    app = QApplication(sys.argv)

    mainWidget = MainWidget()
    mainWidget.show()

    sys.exit(app.exec_())


Traceback:

Traceback (most recent call last):
  File "C:\permafrost3d\venv\lib\site-packages\matplotlib\cbook\__init__.py", line 224, in process
    func(*args, **kwargs)
  File "C:\permafrost3d\venv\lib\site-packages\mpldatacursor\datacursor.py", line 705, in _select
    if contains(anno, fixed_event)[0]:
  File "C:\permafrost3d\venv\lib\site-packages\mpldatacursor\datacursor.py", line 697, in contains
    return artist.contains(event)
  File "C:\permafrost3d\venv\lib\site-packages\matplotlib\text.py", line 1754, in contains
    in_patch, _ = self.arrow_patch.contains(event)
  File "C:\permafrost3d\venv\lib\site-packages\matplotlib\patches.py", line 135, in contains
    codes = self.get_path().codes
  File "C:\permafrost3d\venv\lib\site-packages\matplotlib\patches.py", line 4128, in get_path
    _path, fillable = self.get_path_in_displaycoord()
  File "C:\permafrost3d\venv\lib\site-packages\matplotlib\patches.py", line 4145, in get_path_in_displaycoord
    shrinkB=self.shrinkB * dpi_cor
  File "C:\permafrost3d\venv\lib\site-packages\matplotlib\patches.py", line 2492, in __call__
    clipped_path = self._clip(path, patchA, patchB)
  File "C:\permafrost3d\venv\lib\site-packages\matplotlib\patches.py", line 2447, in _clip
    left, right = split_path_inout(path, insideA)
  File "C:\permafrost3d\venv\lib\site-packages\matplotlib\bezier.py", line 350, in split_path_inout
    ctl_points, command = next(path_iter)
StopIteration

Environment:
Python 3.7.1

depends from pip:
pyqt5, matplotlib, mpldatacursor

platform:
Windows 10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant