mpldatacursor
mpldatacursor copied to clipboard
How to disable interpolate (and enable snaping)
Although the linear interpolation of the given data points is normally a nice feature I want the cursor only snaping to the data points exactly. I can workaround this need by the following code:
x = arange(10); y = x**2
plot(x, y)
points, = plot(x, y, '.', markersize=0)
datacursor(points, hover=True)
It would be nice to achieve the same thing with
plot(x, y)
datacursor(hover=True, snap=True)
Would this be possible?
Anyway, many thanks for your work it is very useful.
@fhgd, my experience is that mpldatacursor snaps to the datapoint if the linestyle is ls='' (empty string) and interpolates if the linestyle is, say ls='-' (minus). (And of course something like markerstyle='.' is needed, but markersize>0 was needed when I tried.) Am I wrong? Am I misunderstanding something?
That being said, I like the idea of a snap=True parameter that works whether or not linestyle is being used.
(using matplotlib 3.1.1, python3.6)