【问题标题】:Jupyter notebook cells doesn't stretch to fit multiple plotsJupyter 笔记本单元格不会拉伸以适应多个绘图
【发布时间】:2019-08-08 07:32:22
【问题描述】:

我正在使用 matplotlib 图表和 ipywidgets 在 ipynb 中显示绘图。然而,当绘制多个图时,单元格不会拉伸以适应所有图。而是显示侧面的滚动条。如何使图能够拉伸并适合单元格?

with output:        
    clear_output()
    plot_a()
    plot_a()
    plot_a()

def plot_a():
    plt.bar(x, y)    
    plt.show()

【问题讨论】:

    标签: matplotlib jupyter-notebook ipywidgets


    【解决方案1】:

    您可以使用 javascript 魔法来获得帮助:

    %%javascript
    IPython.OutputArea.auto_scroll_threshold = 9999;
    

    经过测试并有效:

    i = 0
    while i < 100:
        print('test')
        i +=1
    
    from matplotlib import pyplot as plt
    
    i = 0
    while i < 10:
        plt.plot([1,2])
        plt.show()
        i +=1
    

    【讨论】:

      猜你喜欢
      • 2015-10-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-07-21
      • 1970-01-01
      • 2016-02-04
      • 2016-01-14
      相关资源
      最近更新 更多