OK,这似乎工作:
from bokeh.plotting import figure, output_file, save
from bokeh.models import ColumnDataSource
import pandas as pd
from pandas import HDFStore
from bokeh.palettes import Spectral11
# imports data to dataframe from our storage hdf5 file
# our index column has no name, so this is assigned a name so it can be
# referenced to for plotting
store = pd.HDFStore('<file location>')
df = pd.DataFrame(store['d1'])
df = df.rename_axis('Time')
#the number of columns is the number of lines that we will make
numlines = len(df.columns)
#import color pallet
mypalette = Spectral11[0:numlines]
# remove unwanted columns
col_list = ['Column A', 'Column B']
df = df[col_list]
# make a list of our columns
col = []
[col.append(i) for i in df.columns]
# make the figure,
p = figure(x_axis_type="datetime", title="<title>", width = 800, height = 450)
p.xaxis.axis_label = 'Date'
p.yaxis.axis_label = '<units>'
# loop through our columns and colours
for (columnnames, colore) in zip(col, mypalette):
p.line(df.index, df[columnnames], legend = columnnames, color = colore)
# creates an output file
output_file('<output location>')
#save the plot
save(p)
你可以给你正在试图做的正是一个多一点的信息?在我使用散景和熊猫的经验中,我只是用'''figure' figure()''创建一个图形,然后我循环访问所使用的任何数据,用'''fig.line x = x,y = y,legend =“此行的标签”)'''为我需要的每一行。然后我跳出循环并显示图形,然后显示一个具有多行的单个图形。 – ralston
感谢您的回答。我在其他地方发现了一些代码,它们的作用非常相似请在下面看到我自己的答案。 – pottolom