一个简单的问题-在bokeh中,您可以绘制半径而不是大小的圆,以便在放大或缩小时调整圆。是否可以使用基于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.
答案 0 :(得分:0)
所有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)