问题
I have the following code:
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',
)
Which produces something like:
However, I would like to change the tick locations (to the middle of the color bin). But when I add the following item to the colorbar_opts
dictionary:
'ticker': FixedTicker(ticks=[-3, -2, -1, 0, 1, 2, 3]),
I get this error:
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'
How can I set the locations of the ticks in the colorbar?
I'm using Python 3.7, HoloViews 1.11.2 and Bokeh 1.0.4
来源:https://stackoverflow.com/questions/54687743/how-do-i-manually-set-the-tick-locations-of-a-colorbar-for-a-points-plot-in-holo