Google colaboratory Colaboratory上的GridspecLayout(Ipywidgets)问题

Google colaboratory Colaboratory上的GridspecLayout(Ipywidgets)问题,google-colaboratory,ipywidgets,Google Colaboratory,Ipywidgets,我正在尝试将两个图形放置在网格的各个单元格中,这些单元格是使用Ipywidgets中的GridspecLayout创建的。但是,绘图显示在交互控件的左侧,而不是应该显示在下方 这张图片显示了Colaboratory中的问题,而这张图片显示了我对它的期望(来自Jupyter笔记本,通过Anaconda) 根据使用的前端,下面的代码将复制这两张图片 import pandas as pd import numpy as np import matplotlib.pyplot as plt impor

我正在尝试将两个图形放置在网格的各个单元格中,这些单元格是使用Ipywidgets中的GridspecLayout创建的。但是,绘图显示在交互控件的左侧,而不是应该显示在下方

这张图片显示了Colaboratory中的问题,而这张图片显示了我对它的期望(来自Jupyter笔记本,通过Anaconda)

根据使用的前端,下面的代码将复制这两张图片

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import ipywidgets as widgets
from ipywidgets import GridspecLayout,HTML,Layout,interactive_output 

grid = GridspecLayout(5,8)
testTable = pd.DataFrame({'a':np.random.randn(10),
                          'b':np.random.randn(10),
                          'c':np.random.randn(10),
                          'd':np.random.randn(10),
                          'e':np.random.randn(10)})
def plotData(x):
  plt.figure()
  if len(x) > 1:
    plt.plot(testTable.loc[list(x)])
  else:
    plt.plot(testTable.loc[x])
  plt.show()

# header
grid[0,:] = widgets.HTML(value = f"<center><font size = 6><b><font color='red'>{'Historical Overview'}</b></center>")
# Sub-headlines
grid[1,2] = widgets.HTML(value = f"<center><font size = 2><u><font color='red'>{'Historical Development Graph'}</u></center>")
grid[1,4] = widgets.HTML(value = f"<center><font size = 2><u><font color='red'>{'Upper Pie Chart'}</u></center>")
grid[1,6] = widgets.HTML(value = f"<center><font size = 2><u><font color='red'>{'Lower Pie Chart'}</u></center>")
# Interactive controls and descriptions
grid[2,1] = widgets.HTML(value = f"<center><font color='red'>{'Categories:'}")
grid[2,2] = widgets.SelectMultiple(options=testTable.index,
                                   disabled=False,
                                   value = [0])
grid[2,3] = widgets.HTML(value = f"<center><font color='red'>{'Time periods:'}")
grid[2,4] = widgets.SelectMultiple(options=testTable.index,
                           value = [0],
                           disabled = False)
grid[2,5] = widgets.HTML(value = f"<center><font color='red'>{'Time periods:'}")
grid[2,6] = widgets.Select(options=testTable.columns,
                           value = 'a',
                           disabled = False)
# Graphs
grid[3,1:4] = widgets.interactive_output(plotData, {'x':grid[2,2]});
grid[3,4:8] = interactive_output(plotData, {'x':grid[2,4]});

display(grid)
将熊猫作为pd导入
将numpy作为np导入
将matplotlib.pyplot作为plt导入
将IPyWidget作为小部件导入
从ipywidgets导入GridspecLayout、HTML、Layout、interactive\u输出
网格=网格规格布局(5,8)
testTable=pd.DataFrame({'a':np.random.randn(10),
“b”:np.random.randn(10),
“c”:np.random.randn(10),
“d”:np.random.randn(10),
'e':np.random.randn(10)}
def plotData(x):
plt.图()
如果len(x)>1:
plt.绘图(testTable.loc[列表(x)])
其他:
plt.绘图(testTable.loc[x])
plt.show()
#标题
grid[0,:]=widgets.HTML(值=f“{'history Overview'}”)
#副标题
grid[1,2]=widgets.HTML(值=f“{'history Development Graph'}”)
grid[1,4]=widgets.HTML(值=f“{‘上部饼图’}”)
grid[1,6]=widgets.HTML(值=f“{'Lower piechart'}”)
#交互式控件和说明
grid[2,1]=widgets.HTML(值=f“{'Categories:'}”)
grid[2,2]=widgets.SelectMultiple(options=testTable.index,
禁用=错误,
值=[0])
grid[2,3]=widgets.HTML(值=f“{'时间段:'}”)
grid[2,4]=widgets.SelectMultiple(options=testTable.index,
值=[0],
禁用=错误)
grid[2,5]=widgets.HTML(值=f“{'时间段:'}”)
grid[2,6]=widgets.Select(options=testTable.columns,
值='a',
禁用=错误)
#图表
grid[3,1:4]=widgets.interactive_输出(plotData,{'x':grid[2,2]});
grid[3,4:8]=交互式_输出(plotData,{'x':grid[2,4]});
显示(网格)
我正在通过Anaconda开发Colaboratory和Jupyter笔记本电脑,这两款电脑都是通过Windows 10上的Chrome。 这已经通过Mac上的Firefox在JupyterLab上进行了测试,这就是为什么我怀疑这是Colaboratory的问题

提前,谢谢