如何在全息视图中设置散点圆半径?

How do I set the scatter circle radius in 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)