我正在使用ipywidgets.interactive
来制作交互式图形。事实是,到目前为止,在下拉菜单中有五个选项可供选择,而我将添加第六个。默认情况下,ipywidgets
使下拉菜单垂直对齐。我希望每行有两个Dropdown,所以它们使用的空间更少。
这是我的代码:
import ipywidgets as widgets
#from functools import partial
from ipywidgets import Layout
from ipywidgets import fixed
#grafico_interactivo=partial(grafico_definitivo,fontsize=20,df=df)
style = {'description_width': 'initial'}
com1 = widgets.Dropdown(
options=sorted(df.comuna.unique()),
value='vitacura',
description='District:',
disabled=False)
indicador = widgets.Dropdown(
options=(['cap_rate','price_to_rent','cash_on_cash','payback','arr_m2','vta_m2']),
value='cap_rate',
description='Indicator:',
disabled=False)
filter = widgets.Dropdown(
options=sorted(['todo','casa','dpto']),
value='todo',
description='Show:',
disabled=False)
n_rooms = widgets.Dropdown(
options=[1,2,3,4,5],
description='# rooms:',
layout=Layout(width='30%'),
style=style,
disabled=False)
n_baths = widgets.Dropdown(
options=[1,2,3,4,5],
description='# bathrooms:',
style=style,
disabled=False)
box_layout = Layout(display='flex',
flex_flow='row',
flex_direction='row',
align_items='stretch',
width='70%')
widgets.interactive(grafico_definitivo_dormbaño,comuna=com1,indicador=indicador, n_rooms=n_room, n_baths=n_bath, filter=filter, df=fixed(df), fontsize=fixed(20), layout=box_layout).
但这仍然带来垂直对齐,如下所示:
我能做些什么吗?谢谢