为jupyter小部件输出调整布局

时间:2019-03-19 00:56:12

标签: jupyter-notebook ipywidgets

下面的代码使用户可以交互式显示连续的图。

我希望从该图中隐藏标题“图1”及其灰色框。 我读了this guide,但找不到答案。

enter image description here

import ipywidgets as widgets
from IPython.display import display, clear_output
from traitlets import CInt, link

class Counter(widgets.DOMWidget):
    value = CInt(0, sync=True)


counter = Counter()
def button_plus(name):
    if counter.value != passage_list[-1]  :
        counter.value = passage_list[passage_list.index(counter.value)+1] 
    else :
        print("last passage from the list")

def button_minus(name):
    if passage_list.index(counter.value) != 0  :
        counter.value = passage_list[passage_list.index(counter.value)+1] 
    else : 
        print("first passage from the list")


# 1 step forward button
wplus = widgets.Button(description='> Next passage')

# 1 step backward button
wminus = widgets.Button(description='Previous passage <')

# dropdown widget with passages timestamp
wpick = widgets.Dropdown(
    options=passage_list,
    value=passage_list[0],
    description='Passage:',
    disabled=False,
)
wplus.on_click(button_plus)
wminus.on_click(button_minus)

link((wpick, 'value'), (counter, 'value'));

#display(wminus, wpick,wplus)
ui = widgets.HBox([wminus, wpick,wplus])

out = widgets.interactive_output(plot2_passage, {'passage': wpick})

display(ui, out)

2 个答案:

答案 0 :(得分:0)

我认为使用的是默认的matplotlib notebook后端,它提供标题栏。交互性使您可以平移/缩放图表。

尝试将%matplotlib inline添加到单元格的顶部。应该可以消除灰色条,但是您可能会失去缩放/平移功能。

答案 1 :(得分:0)

我最后编辑了custom.css文件:

    在浏览器中的
  1. F12中,找到用于灰色条的类: “ ui-dialog-titlebar”
  2. 在Windows上找到custom.css:C:\ Users \ user.jupyter \ custom \ custom.css
  3. 将这些行添加到custom.css文件的末尾:

    .ui-dialog-titlebar {     显示:无; }