How to display X, Y position on mouse hover?

1,981 views
Skip to first unread message

Ankit Kakkar

unread,
May 2, 2018, 1:20:15 AM5/2/18
to pyqtgraph
Hi,

How can we get the real-time X, Y position on mouse hover on m PlotWidget?


I have attached a screenshot of the functionality (anything similar) i want. 
Mouse hover.jpg

Luke Campagnola

unread,
May 2, 2018, 10:00:17 AM5/2/18
to pyqt...@googlegroups.com
Hi Ankit,
Have a look at examples/crosshair.py; that should help.

--
You received this message because you are subscribed to the Google Groups "pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/996cc060-277e-4516-a718-664fc515cff5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ankit Kakkar

unread,
May 3, 2018, 2:20:37 AM5/3/18
to pyqtgraph
Hi Luke,

Thanks for the suggestion. This seems good.

However, on line 65 of the crosshair example, it says:

vb = p1.vb

This line doesn't seems to work for me. As in my case, p1 refers to PlotWidget, which does not have any attribute as vb. Could you please elaborate on what does it mean?

If it refers to ViewBox(), then do I need to add another viewbox inside my plotwidget ?




On Wednesday, May 2, 2018 at 7:30:17 PM UTC+5:30, Luke Campagnola wrote:
Hi Ankit,
Have a look at examples/crosshair.py; that should help.
On Tue, May 1, 2018 at 10:20 PM, Ankit Kakkar <ankit....@gmail.com> wrote:
Hi,

How can we get the real-time X, Y position on mouse hover on m PlotWidget?


I have attached a screenshot of the functionality (anything similar) i want. 

--
You received this message because you are subscribed to the Google Groups "pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+...@googlegroups.com.

Ankit Kakkar

unread,
May 3, 2018, 2:26:22 AM5/3/18
to pyqtgraph
Error message for your reference:

Traceback (most recent call last):


 
File "R:/New Structure/West 70/Single Stock Analyzer/Drafts/Ankit/Scanner V3 - 3 May/Scanner V3.5.py", line 1234, in plot
    vb
= w2.vb


 
File "C:\ProgramData\Anaconda2\lib\site-packages\pyqtgraph\widgets\PlotWidget.py", line 79, in __getattr__
   
raise NameError(attr)


NameError: vb

Luke Campagnola

unread,
May 3, 2018, 12:14:33 PM5/3/18
to pyqt...@googlegroups.com
There are three containers here: PlotWidget (the Qt widget) contains a PlotItem (the Qt graphics item), which contains two AxisItems and a ViewBox.
So to get the ViewBox from the PlotWidget, it's `plotwidget.plotItem.vb`.

To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/1c65ad03-91b7-4c82-a942-bb938bfb9e3f%40googlegroups.com.

Ankit Kakkar

unread,
May 4, 2018, 12:33:37 AM5/4/18
to pyqtgraph
Got it, thanks. I actually got it from your post on Stack overflow. Thanks Luke.
Reply all
Reply to author
Forward
0 new messages