How do I manually set the tick locations of a colorbar for a Points plot in HoloViews?

ⅰ亾dé卋堺 提交于 2020-01-15 09:58:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!