如何手动设置全息视图颜色条的限制? [英] 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}]
我知道...
TypeError [Call holoviews.ipython.show_traceback() for details]
MetaModel object got multiple values for keyword argument 'ticker'
这是回溯...
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'
推荐答案
可以在HoloViews Elements的 Dimension
对象上设置颜色范围和所有其他范围.声明 HeatMap
时,将创建三个(或更多)尺寸.前两个是与HeatMap的x轴和y轴相对应的关键尺寸( kdims
).其次,存在两个或多个值维度( vdims
),其中第一个映射到颜色范围.构造对象时,可以明确声明尺寸范围.在这里,我们设置"z"维度的颜色,该颜色应该是您要绘制的任何列的名称:
The color range and all other ranges can be set on the Dimension
objects of HoloViews Elements. When you declare a HeatMap
three (or more) dimensions are created. The first two are the key dimensions (kdims
) corresponding to the x- and y-axis of the HeatMap. Secondly there are two or more value dimensions (vdims
) the first of which is mapped to the color range. 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:
hv.HeatMap(..., vdims=hv.Dimension('z', range=(0, 10)))
您还可以使用 redim
界面在事后覆盖范围.当您有一个对象集合时,这也将起作用,因为它将对包含该维度的所有对象递归设置范围并返回一个新对象.看起来像这样:
You can also use the redim
interface to override the range after the fact. 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))
这篇关于如何手动设置全息视图颜色条的限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!