我想点击并拖动散点图散点图的点.任何想法如何做到这一点?
(编辑:这是我想做的一个例子)
有关散点的示例,下面的代码会生成在此页面中间找到的散点图.
from bokeh.plotting import figure, output_file, show
# create a Figure object
p = figure(width=300, height=300, tools="pan,reset,save")
# add a Circle renderer to this figure
p.circle([1, 2.5, 3, 2], [2, 3, 1, 1.5], radius=0.3, alpha=0.5)
# specify how to output the plot(s)
output_file("foo.html")
# display the figure
show(p)
Run Code Online (Sandbox Code Playgroud)
多手势编辑工具只是最新添加的功能,其版本为0.12.14。您可以在《用户指南》的“ 编辑工具”部分中找到更多信息。
特别是为了能够按照OP中所述移动点,请使用PointDrawTool:
这是一个可以运行的完整示例,该示例还具有一个数据表,该数据表显示字形在移动时的更新坐标(您需要首先激活工具栏中的工具,默认情况下处于关闭状态):
from bokeh.plotting import figure, output_file, show, Column
from bokeh.models import DataTable, TableColumn, PointDrawTool, ColumnDataSource
output_file("tools_point_draw.html")
p = figure(x_range=(0, 10), y_range=(0, 10), tools=[],
title='Point Draw Tool')
p.background_fill_color = 'lightgrey'
source = ColumnDataSource({
'x': [1, 5, 9], 'y': [1, 5, 9], 'color': ['red', 'green', 'yellow']
})
renderer = p.scatter(x='x', y='y', source=source, color='color', size=10)
columns = [TableColumn(field="x", title="x"),
TableColumn(field="y", title="y"),
TableColumn(field='color', title='color')]
table = DataTable(source=source, columns=columns, editable=True, height=200)
draw_tool = PointDrawTool(renderers=[renderer], empty_value='black')
p.add_tools(draw_tool)
p.toolbar.active_tap = draw_tool
show(Column(p, table))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2395 次 |
| 最近记录: |