我有以下代码:
import numpy as np
import holoviews as hv
from bokeh.models import FixedTicker
hv.extension('bokeh')
points = hv.Points(np.random.randint(-3, 4, (20, 3)), vdims=['interval'])
points.opts(
color='interval',
size=10,
colorbar=True,
color_levels=7,
colorbar_opts={
'major_label_overrides': {
-3: 'high',
-2: 'medium',
-1: 'low',
0: 'none',
1: 'low',
2: 'medium',
3: 'high'
},
'major_label_text_align': 'left',
},
cmap='RdYlGn',
)
哪个会产生类似的内容:
但是,我想更改刻度位置(到颜色容器的中间)。但是,当我将以下项目添加到colorbar_opts
字典中时:
'ticker': FixedTicker(ticks=[-3, -2, -1, 0, 1, 2, 3]),
我收到此错误:
Traceback (most recent call last):
File "C:\Users\pablo\AppData\Local\Continuum\anaconda3\envs\sandbox-py3.7\lib\site-packages\holoviews\plotting\bokeh\element.py", line 1017, in _init_glyphs
renderer, glyph = self._init_glyph(plot, mapping, properties)
File "C:\Users\pablo\AppData\Local\Continuum\anaconda3\envs\sandbox-py3.7\lib\site-packages\holoviews\plotting\bokeh\element.py", line 1561, in _init_glyph
self._draw_colorbar(plot, v, k[:-12])
File "C:\Users\pablo\AppData\Local\Continuum\anaconda3\envs\sandbox-py3.7\lib\site-packages\holoviews\plotting\bokeh\element.py", line 1392, in _draw_colorbar
**dict(opts, **self.colorbar_opts))
TypeError: MetaModel object got multiple values for keyword argument 'ticker'
如何在颜色栏中设置刻度线的位置?
我正在使用Python 3.7,HoloViews 1.11.2和Bokeh 1.0.4