【发布时间】:2018-05-21 12:31:35
【问题描述】:
我正在制作一个简单的Curve,x 轴上的值以秒(SI 单位)表示,值大约为纳秒。
我想使用hv.Dimension 对象格式化轴刻度,如How to control Holoviews y-tick format? 中所述。此示例在使用 matplotlib 后端时完美运行,但在使用(默认)散景后端时不起作用。
我目前有一个自定义格式化程序,它将我的所有值乘以所需的数量并指定正确的单位。
xs = np.linspace(0, 15e-6, 500)
xfmt = lambda x: round(x*1e6, ndigits=3)
c = hv.Curve({'x':xs, 'y':step_lowpass(xs, tau=.1e-6)},
kdims=[hv.Dimension('x', label='Time', unit='$\mu$s', value_format=xfmt)])
这在使用 matplotlib 后端时非常有效,但是在使用 Bokeh 后端时它不起作用,并给出以下警告:
WARNING:root:main: x dimension formatter could not be converted to tick formatter. Pyscript raised an error: list index out of range
并且不使用格式化程序。我还尝试直接指定bokeh.models.formatters.FuncTickFormatter 对象作为value_format 的参数,但这不起作用,因为这些对象不能直接调用,而是包含将刻度格式化为属性所需的代码。
【问题讨论】: