Ich habe ein Wörterbuch mit Listen von Bokeh-Figuren. Ich rufe diese und platziere 2 Plots auf einem Layout und setze sie in 3 oder 4 Tabs.Bokeh-Plots rendern übereinander, wenn Layouts in Tabs eingefügt werden
Wenn ich das Dokument öffne, sieht es so aus, als hätte es nur ein Plot, aber man merkt, dass es einen zweiten Plot dahinter in der Werkzeugleiste gibt und manchmal kleine Teile des zweiten Plots.
Wenn ich nur show(layout)
es sieht gut aus, ist es nur, wenn ich versuche, das Layout innerhalb einer Registerkarte, die es nicht richtig zu rendern.
Ich habe das Problem erstellt, wie ich es eingerichtet habe. Das Unten ist ein bisschen lang, aber ich möchte ein komplettes Beispiel haben. Der erste Teil erstellt nur alle Plots. Bitte beachten Sie den Verzeichnispfad, der geändert werden muss.
from bokeh.charts import Bar, output_file, show, BoxPlot, Histogram, Scatter
from bokeh.sampledata.autompg import autompg as df
from bokeh.models.widgets import Tabs, Panel
from bokeh.layouts import layout
import os
directory = r'/Users/user/bokehApp'
bar = []
p = Bar(df, 'cyl', values='mpg', title="Total MPG by CYL")
bar.append(p)
p = Bar(df, label='yr', values='mpg', agg='mean',
title="Average MPG by YR")
bar.append(p)
p = Bar(df, 'yr', values='displ',
title="Total DISPL by YR", bar_width=0.4)
bar.append(p)
p = Bar(df, 'yr', values='displ',
title="Total DISPL by YR", color="wheat")
bar.append(p)
box = []
p = BoxPlot(df, values='mpg', label='cyl',
title="MPG Summary (grouped by CYL)")
box.append(p)
p = BoxPlot(df, values='mpg', label=['cyl', 'origin'],
title="MPG Summary (grouped by CYL, ORIGIN)")
box.append(p)
p = BoxPlot(df, values='mpg', label='cyl', color='#00cccc',
title="MPG Summary (grouped by CYL)")
box.append(p)
p = BoxPlot(df, values='mpg', label='cyl', color='cyl',
title="MPG Summary (grouped and shaded by CYL)")
box.append(p)
hist = []
p = Histogram(df['mpg'], title="MPG Distribution")
hist.append(p)
p = Histogram(df, 'hp', title="HP Distributioan")
hist.append(p)
p = Histogram(df, values='displ', title="DISPL Distribution")
hist.append(p)
p = Histogram(df, values='mpg', bins=50,
title="MPG Distribution (50 bins)")
hist.append(p)
scat = []
p = Scatter(df, x='mpg', y='hp', title="HP vs MPG",
xlabel="Miles Per Gallon", ylabel="Horsepower")
scat.append(p)
Das obige ist alle der Plots, die ich von der High-Level-Charts-Seite genommen habe, ist unten das Problem.
dataDict = {'Bar': bar, 'Box': box, 'Hist': hist, 'Scat': scat}
plots = ['Bar', 'Box', 'Hist']
for plt in plots:
plotFig = dataDict[plt]
tabList = [plotFig[0:2],plotFig[2:4]]
tabTitle =['tab1', 'tab2']
panel = []
output_file(os.path.join(directory, plt+'.html'), title = plt + 'plots', autosave = False, mode = 'cdn', root_dir = None)
for tab, title in zip (tabList, tabTitle):
l = layout(children = [
tab], sizing_mode = 'scale_width')
t = Panel(child = l, title = title)
panel.append(t)
tabs = Tabs(tabs = panel)
show(tabs)
Dank
Ich glaube nicht, dass das etwas für mich tut. Ich habe zwei Plots pro Tab innerhalb eines Layouts und in jedem Tab/Layout sind Plots übereinander gerendert. Es sieht nur wie ein Diagramm aus, aber Sie können zwei Werkzeugleisten sehen. Mein Beispiel oben ist ein vollständiges Beispiel, das das Problem neu erstellt, wenn Sie die Ausgabe ausführen und anzeigen möchten. –