[Matplotlib-devel] Getting MultiCursor Subplots values (coordinates)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Matplotlib-devel] Getting MultiCursor Subplots values (coordinates)

A.Brahim
I'm using this code to generate subplots with multiCursor crossing plots, and
I want to get values (cursor coordinates) for all existing plots at the same
time to show them in labels (on mouse motion).


import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import MultiCursor

t = np.arange(0.0, 2.0, 0.01)
s1 = np.sin(2*np.pi*t)
s2 = np.sin(4*np.pi*t)
fig = plt.figure()
ax1 = fig.add_subplot(211)
ax1.plot(t, s1)


ax2 = fig.add_subplot(212, sharex=ax1)
ax2.plot(t, s2)

multi = MultiCursor(fig.canvas, (ax1, ax2), color='r', lw=1)
plt.show()



<http://matplotlib.1069221.n5.nabble.com/file/t5115/U16Dl.png>



--
Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-devel-f28077.html
_______________________________________________
Matplotlib-devel mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-devel
Reply | Threaded
Open this post in threaded view
|

Re: Getting MultiCursor Subplots values (coordinates)

tcaswell
It looks like MultiCursor does not directly store that information, it just implicitly stores it in the positions of the lines.  I would look at `multi.vlines` and `multi.hlines`, loop over those and extract the information you need.

Tom

On Thu, Nov 30, 2017 at 11:06 AM A.Brahim <[hidden email]> wrote:
I'm using this code to generate subplots with multiCursor crossing plots, and
I want to get values (cursor coordinates) for all existing plots at the same
time to show them in labels (on mouse motion).


import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import MultiCursor

t = np.arange(0.0, 2.0, 0.01)
s1 = np.sin(2*np.pi*t)
s2 = np.sin(4*np.pi*t)
fig = plt.figure()
ax1 = fig.add_subplot(211)
ax1.plot(t, s1)


ax2 = fig.add_subplot(212, sharex=ax1)
ax2.plot(t, s2)

multi = MultiCursor(fig.canvas, (ax1, ax2), color='r', lw=1)
plt.show()



<http://matplotlib.1069221.n5.nabble.com/file/t5115/U16Dl.png>



--
Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-devel-f28077.html
_______________________________________________
Matplotlib-devel mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-devel

_______________________________________________
Matplotlib-devel mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-devel