python - Bokeh Circle 半径不接受浮点数
问题描述
我想绘制具有特定半径的圆形标记。用整数绘制这些圆形标记效果很好。
cavity_glyph = Circle(
x='x_coordinate',
y='y_coordinate',
radius=1.,
radius_dimension='max',
radius_units='data',
line_color='cavity_color'
)
但是,当我为半径输入浮点数时,没有绘制任何内容
cavity_glyph = Circle(
x='x_coordinate',
y='y_coordinate',
radius=0.5,
radius_dimension='max',
radius_units='data',
line_color='cavity_color'
)
我通读了散景参考资料,但找不到解决方案。
我期望半径为 0.5 的圆圈,而不是空地
解决方案
我无法用您的示例重现您的错误。检查您的 Bokeh 版本可能很有用,它可能是一个已在较新版本中修复的错误 ( bokeh -v
)。这是一个使用 Bokeh 1.2.0 测试的工作示例:
from bokeh.plotting import figure, output_file, show
from bokeh.models import ColumnDataSource
from bokeh.models.markers import Circle
output_file("line.html")
p = figure(plot_width=800, plot_height=800)
data = {'x': [1, 2, 3, 4, 5], 'y': [5, 6, 7, 8, 9], 'radius': [0.1, 0.3, 0.5, 0.7, 0.9]}
source = ColumnDataSource(data)
data2 = {'x': [1, 2, 3, 4, 5], 'y': [9, 8, 7, 6, 5], 'radius': [0.1, 0.3, 0.5, 0.7, 0.9]}
source2 = ColumnDataSource(data2)
p.circle(x='x', y='y', radius='radius', color='navy', alpha=0.5, source=source)
cavity_glyph = Circle(
x='x',
y='y',
radius='radius',
fill_color='red',
fill_alpha=0.5,
radius_dimension='max',
radius_units='data'
)
p.add_glyph(source2, cavity_glyph)
show(p)
推荐阅读
- python - 熊猫如何根据第一列的值拆分数据框?
- azure - 在 azure 机器学习工作室中打开笔记本
- node.js - Gitlab CD 在部署到谷歌应用引擎期间崩溃
- javascript - 计算函数内数组中元素的总和
- reactjs - useState 不会在 React 中更新它的值
- python - 如何调试这个简单的终端 Hangman Python 3 脚本?
- erlang - 使用 rebar3 编译一个文件的工作流程是什么?
- dataframe - Krangl:计算列中包含在另一个列表中的元素数
- javascript - 以编程方式实例化 vuetify-components
- python - Pandas.replace() 不会改变数据