首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Bokeh -地块的垂直布局

Bokeh -地块的垂直布局
EN

Stack Overflow用户
提问于 2020-05-22 10:46:17
回答 1查看 173关注 0票数 0

我正试着垂直显示两个情节。我在show(column(west_fig, east_fig))收到一条错误消息

你能帮我理解一下错误信息吗?

版本: BokehJS 1.4.0成功加载。

注意:我在木星笔记本上运行这段代码。

代码语言:javascript
复制
## Detailed error message:

8#中的跟踪(最近一次调用)在垂直配置-> 10显示(列(west_fig,( east_fig))

RuntimeError:模型只能由单个文档DaysTicker(id='2330',.)拥有。已经在医生里了

代码语言:javascript
复制
# Bokeh libraries
from bokeh.io import output_file, output_notebook
from bokeh.plotting import figure, show
from bokeh.layouts import column

# output to notebook
output_notebook()

# Plot the two visualizations in a vertical configuration
show(column(west_fig, east_fig))

####### west_fig #######

# Bokeh libraries
from bokeh.plotting import figure, show
from bokeh.io import output_file, output_notebook
from bokeh.models import ColumnDataSource, CDSView, GroupFilter

# Output to notebook
output_notebook()

# Convert `stDate` column to datetime column
west_top_2['stDate'] = pd.to_datetime(west_top_2['stDate'], format = '%Y-%m-%d')


# Create a ColumnDataSource
west_cds = ColumnDataSource(west_top_2)

# Create views for each team
rockets_view = CDSView(source = west_cds,
                       filters = [GroupFilter(column_name = 'teamAbbr', group = 'HOU')]   
                      )
warriors_view = CDSView(source = west_cds,
                        filters = [GroupFilter(column_name = 'teamAbbr', group = 'GS')]
                       )

# Create and configure the figure
west_fig = figure(x_axis_type = 'datetime',
                  plot_height = 500,
                  plot_width = 600,
                  title = 'Western Conference Top 2 Teams Wins Race, 2017-18',
                  x_axis_label = 'Date',
                  y_axis_label = 'Wins',
                  toolbar_location = None
                 )

# Render the race as step lines
west_fig.step('stDate', 'gameWon', source = west_cds, view = rockets_view, color = '#CE1141', legend = 'Rockets')
west_fig.step('stDate', 'gameWon', source = west_cds, view = warriors_view, color = '#006BB6', legend = 'Warriors')

# Move the legend to the upper top-left corner
west_fig.legend.location = "top_left"

# Show the plot
show(west_fig)

####### east_fig #########

import pandas as pd

# Bokeh libraries
from bokeh.plotting import figure, show
from bokeh.io import output_file, output_notebook
from bokeh.models import ColumnDataSource, CDSView, GroupFilter


# Output to notebook
output_notebook()

# Convert stDate to datetime column
standings['stDate'] = pd.to_datetime(standings['stDate'], format = '%Y-%m-%d')

# Create a ColumnDataSource
standings_cds = ColumnDataSource(standings)

# Create views for each team
celtics_view = CDSView(source=standings_cds,
                       filters = [GroupFilter(column_name = 'teamAbbr', group = 'BOS')]
                      )
raptors_view = CDSView(source=standings_cds,
                       filters = [GroupFilter(column_name = 'teamAbbr', group = 'TOR')]
                      )

# Configure Figure object
east_fig = figure(x_axis_type = 'datetime',
                  plot_height = 500,
                  plot_width = 600,
                  title = 'Eastern Conference Top 2 Teams Wins Race, 2017-18',
                  x_axis_label = 'Date',
                  y_axis_label = 'Wins',
                  toolbar_location = None
                 )

# Render the race as step lines
east_fig.step('stDate', 'gameWon', color = '#007A33', legend = 'Celtics', 
               source = standings_cds, view = celtics_view)
east_fig.step('stDate', 'gameWon', color = '#CE1141', legend = 'Raptors',
               source = standings_cds, view = raptors_view)

# Move the legend to the upper left hand corner
east_fig.legend.location = "top_left"

# Show the plot
show(east_fig)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-05-22 11:25:11

在代码末尾只做一个显示语句。这意味着删除show(column(west_fig, east_fig)), show(west_fig), show(east_fig)行并在代码show(column(west_fig, east_fig))的末尾添加

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61953239

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档