如何在全息图中设置散射圆半径

  • 本文关键字:设置 全息图 holoviews
  • 更新时间 :
  • 英文 :


简单问题-在散焦图中,您可以用半径而不是大小绘制圆,以便在放大或缩小时调整圆。有可能用基于全息图的散射来实现这一点吗?它目前没有设置半径的选项,我也不知道如何以另一种方式提供它(例如渲染(。可能是用户错误,所以提前道歉,非常感谢。

import holoviews as hv
hv.extension('bokeh')
from bokeh.plotting import figure, show
x=(1,2,3)
y=(1,2,3)
p=figure()
p.scatter(x, y, radius=0.2)
show(p) # bokeh plot working as expected
scatter=hv.Scatter((x,y)).opts(marker="circle", size=20)
scatter # holoviews plot, cannot code "radius" for code above - causes error.

所有hv.Scatter图都基于Bokeh的Scatter标记,该标记在其文档字符串中有此部分:

Note that circles drawn with `Scatter` conform to the standard Marker
interface, and can only vary by size (in screen units) and *not* by radius
(in data units). If you need to control circles by radius in data units,
you should use the Circle glyph directly.

这意味着你不能使用hv.Scatter,你必须使用其他东西:

import holoviews as hv
import param
from holoviews.element.chart import Chart
from holoviews.plotting.bokeh import PointPlot
hv.extension('bokeh')
x = (1, 2, 3)
y = (1, 2, 3)

class Circle(Chart):
group = param.String(default='Circle', constant=True)
size = param.Integer()

class CirclePlot(PointPlot):
_plot_methods = dict(single='circle', batched='circle')
style_opts = ['radius' if so == 'size' else so for so in PointPlot.style_opts if so != 'marker']

hv.Store.register({Circle: CirclePlot}, 'bokeh')
scatter = Circle((x, y)).opts(radius=0.5)

最新更新