Hi all. I’m building an interactive tool on top of bokeh and it seems like I can’t retreive coordinates of drawn polygons.
Here’s a bit of code that I am using;
from bokeh.plotting import figure, output_file, show
from bokeh.models import PolyDrawTool, PolyEditTool
p = figure(width=400, height=400, title='HumanClassifier')
source = ColumnDataSource(data=df)
p.circle(x='bill_length_mm', y='bill_depth_mm', color='gray', source=source)
p1 = p.patches([], [], fill_color='red', fill_alpha=0.4, line_alpha=0.0)
p2 = p.patches([], [], fill_color='green', fill_alpha=0.4, line_alpha=0.0)
p3 = p.patches([], [], fill_color='blue', fill_alpha=0.4, line_alpha=0.0)
c1 = p.circle([], [], size=5, color='black')
d1 = PolyDrawTool(renderers=[p1])
d1.custom_icon = "red.png"
d2 = PolyDrawTool(renderers=[p2])
d2.custom_icon = "green.png"
d3 = PolyDrawTool(renderers=[p3])
d3.custom_icon = "blue.png"
edit_tool = PolyEditTool(renderers=[p1, p2, p3], vertex_renderer=c1)
p.add_tools(d1, d2, d3, edit_tool)
p.toolbar.active_drag = edit_tool
show(p)
This is what the chart looks like after I’ve drawn a figure in it.
The question now is; how do I get the coordinates of the drawn polygon? I can’t seem to find it anywhere in the documentation.