Drawing lines in a figure

Hello,

I’m trying to create an app the allows drawing straight lines on a figure plotting an image. I couldn’t find anything suitable in the “Configuring Plot Tools” page, so I had a look at the bokeh.models.tools docs. I’m sure using TapTool or something I can create a callback that draws lines between even point selections, but this will not allow interactively selecting the lines themselves and making any actions on them through the plot (or will it? I couldn’t find a reference to anything like that other). My conclusion so far is that my best option would be to create a custom tool, but unfortunately my JS is kind of like my French, I can understand a lot of what’s going on but I couldn’t express anything too complicated if my life depended on it.

So, my question is: am I missing something? or is creating a custom tool in JS really the best option? Does anyone have a more elegant solution using the existing functionality?

If I’m not missing anything and this is a bit complicated at the moment, any chance the ability to draw vectors like that and interact with them in the plot is potentially important enough to be considered in future releases? I believe it could prove useful in many scientific applications. In the context of the app I’m working on, we need to draw the direction of blood flow in blood vessels within an ROI (Rect glyph managed with BoxEditTool) in order to compute the velocity of flow, but I’m sure it could be useful for a great variety of more generic applications.

Thanks everyone! All the best,

Zvi

Hi Zvi,

I solved a similar problem using PolyDrawTool and PolyEditTool, please have a look at these links:
https://bokeh.pydata.org/en/latest/docs/reference/models/tools.html#bokeh.models.tools.PolyDrawTool
https://bokeh.pydata.org/en/latest/docs/reference/models/tools.html#bokeh.models.tools.PolyEditTool

Best regards!