HoloViz version of Matlab "ginput"?

A colleague asked me:

“Hi - If you were going to write an interactive program to select pixels from an image in Python, would you use Holoviz? If not, what? (Basically, need to do what Matlab would do with ginput).”

Matlab’s ginput allows you to click points on a plot and get a list of [x,y] locations back.

This notebook works (screen grab below), but seems a bit complex.


Is there a simpler way?

Would HoloViews Streams not be what you are looking for? For example the Tap stream which returns the x,y point you click. C.f. Tap — HoloViews 1.14.5 documentation

@Marc , ah good reminder of the Tap stream! I guess some folks would prefer Tap and some PointDraw, depending on the use case. Good to know that you can initialize empty points, like:

points = hv.Points([])
1 Like