为什么y不限时值,而显示为???
时间: 2024-04-14 17:28:11 浏览: 9
如果你希望在悬停时显示 `Y` 值为 "???",你可以在 `HoverTool` 的 `tooltips` 参数中将 `Y Value` 的值设置为 `"???"`。以下是一个示例代码:
```python
from bokeh.plotting import figure, show
from bokeh.models import HoverTool
from bokeh.sampledata.iris import flowers
# 创建一个新的图表
p = figure(plot_width=400, plot_height=400)
# 添加散点图
scatter = p.circle(x='petal_length', y='petal_width', source=flowers)
# 配置悬停工具
hover = HoverTool(tooltips=[('Species', '@species'), ('Petal Length', '@petal_length'), ('Petal Width', '@petal_width'),
('Y Value', '???')], renderers=[scatter])
# 添加悬停工具到图表
p.add_tools(hover)
# 显示图表
show(p)
```
在上述代码中,`tooltips` 参数中添加了一个新的条目 `'Y Value'`,并将其值设置为 `'???'`。这样,在悬停时,`Y` 值将显示为 `"???"`。你可以根据需要自定义显示的文本。