简体   繁体   English

如何手动设置holoview的彩条的限制?

[英]How do I manually set the limits of a holoview's colorbar?

When I try to input my own ticker... 当我尝试输入我自己的股票代码时......

In an earlier cell... 在较早的细胞中......

ticker = FixedTicker(ticks=range(0, 10))

In the following cell... 在以下单元格中......

%%opts HeatMap [colorbar=True colorbar_opts={'ticker': ticker}]

I get... 我明白了......

TypeError [Call holoviews.ipython.show_traceback() for details]
MetaModel object got multiple values for keyword argument 'ticker'

Here's the traceback... 这是追溯......

  File "/Users/ahuang11/anaconda3/envs/tf/lib/python3.6/site-packages/holoviews/plotting/bokeh/element.py", line 757, in _init_glyphs
    renderer, glyph = self._init_glyph(plot, mapping, properties)

  File "/Users/ahuang11/anaconda3/envs/tf/lib/python3.6/site-packages/holoviews/plotting/bokeh/element.py", line 1201, in _init_glyph
    self._draw_colorbar(plot, self.handles['color_mapper'])

  File "/Users/ahuang11/anaconda3/envs/tf/lib/python3.6/site-packages/holoviews/plotting/bokeh/element.py", line 1100, in _draw_colorbar
    **dict(opts, **self.colorbar_opts))

TypeError: MetaModel object got multiple values for keyword argument 'ticker'

The color range and all other ranges can be set on the Dimension objects of HoloViews Elements. 可以在HoloViews Elements的Dimension对象上设置颜色范围和所有其他范围。 When you declare a HeatMap three (or more) dimensions are created. 声明HeatMap会创建三个(或更多)维度。 The first two are the key dimensions ( kdims ) corresponding to the x- and y-axis of the HeatMap. 前两个是与kdims的x轴和y轴对应的关键尺寸( kdims )。 Secondly there are two or more value dimensions ( vdims ) the first of which is mapped to the color range. 其次,有两个或多个值维度( vdims ),其中第一个映射到颜色范围。 Dimension ranges can be explicitly declared when constructing the object. 可以在构造对象时显式声明维度范围。 Here we set the color of the 'z' Dimension, which should be the name of whatever column you are plotting: 在这里我们设置'z'维度的颜色,它应该是您正在绘制的任何列的名称:

hv.HeatMap(..., vdims=hv.Dimension('z', range=(0, 10)))

You can also use the redim interface to override the range after the fact. 您也可以使用redim界面覆盖事后的范围。 This will also work when you have a collection of objects, as it will set the range recursively on all objects which contain that dimension and return a new object. 当您拥有一组对象时,这也将起作用,因为它将在包含该维度的所有对象上递归设置范围并返回一个新对象。 That looks something like this: 看起来像这样:

heatmap = hv.HeatMap(...)
redimensioned_heatmap = heatmap.redim.range(z=(0, 10))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM