如何在散景图中显示工具栏

问题描述 投票:0回答:1

我在向我的代码添加工具栏图标时遇到麻烦。以下是我下面的代码,我希望能够看到每个工具的工具栏图标。

import matplotlib.pyplot as plt
import numpy as np
from bokeh.io import output_file, output_notebook
from bokeh.plotting import figure, show
from bokeh.models import ColumnDataSource, CDSView, HoverTool,BoxSelectTool,WidgetBox
from bokeh.layouts import row, column, gridplot
from bokeh.models.widgets import Tabs, Panel
import csv
output_file('btcnov1.html')  # Render to static HTML, or 
output_notebook()  # Render inline in a Jupyter Notebook
%matplotlib inline

btc412 = pd.read_excel('11-01 412-605.xlsx',sheet_name="Sheet1")
now1 = pd.DataFrame(btc412, columns=['size','unix'])
now2 = pd.DataFrame(btc412, columns=['unix','price','size'])
x = now1.loc[now1["size"] == 31, "unix"]
y = now1.loc[now1["size"] == 31, "size"]
z= now2.loc[now2["size"] == 31, "unix"]
w=now2.loc[now2["size"] == 31, "price"]
hover = HoverTool(tooltips=[('index', "$index"),
   ("(x,y)", "(@x, @y)"),
("(z,w)", "(@z, @w)"),
])

tools=["pan,wheel_zoom,box_zoom,reset,save,hover,xbox_zoom"]
# Set up the figure(s)
fig = figure(plot_height=600, plot_width=900,tools=tools,
             title='BTC NOV 1, 4:12-6:05 am',
             x_axis_label='Unix', y_axis_label='Size',
             toolbar_location=None)

fig.circle(x, y, 
         color='#CE1141', legend='size')

fig.line(z,w, color='#CE1141', legend='price')


show(fig)

我希望能够看到HoverTool的工具栏,选择工具等。另外,我要添加什么来保存绘图?

python pandas bokeh toolbar
1个回答
0
投票

您已通过设置toolbar_location=None明确要求不提供工具栏。因此,如果您需要工具栏,请不要这样做。

© www.soinside.com 2019 - 2024. All rights reserved.