prevent plot from showing in jupyter notebook

后端 未结 6 2180
梦毁少年i
梦毁少年i 2020-12-04 23:19

How can I prevent a specific plot to be shown in Jupyter notebook? I have several plots in a notebook but I want a subset of them to be saved to a file and not shown on the

6条回答
  •  -上瘾入骨i
    2020-12-04 23:53

    On Jupyter 6.0, I use the following snippet to selectively not display the matplot lib figures.

    import matplotlib as mpl
    
    ...
    
    backend_ =  mpl.get_backend() 
    mpl.use("Agg")  # Prevent showing stuff
    
    # Your code
    
    mpl.use(backend_) # Reset backend
    

提交回复
热议问题