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