简体   繁体   English

使用魔法时看不到在 Jupyter 笔记本中创建的 plot:%matplotlib 笔记本。 Windows 10 和铬

[英]Not possible to see the plot created in Jupyter notebooks when using magic: %matplotlib notebook. Windows 10 and Chrome

Hi everyone.大家好。 I am running jupyter notebook through Chrome and Windows 10. the versions are: Windows 10 Chrome Version 84.0.4147.105 (Official Build) (64-bit) I am using the magic %matplotlib notebook.我正在通过 Chrome 和 Windows 10 运行 jupyter 笔记本。版本是:Windows 10 Chrome 版本 84.0.4147.105(官方构建)(64 位)我正在使用神奇的 %matplotlib 笔记本。 To be able to zoom in and out in the plot.能够放大和缩小 plot。 The code works in other machines with same windows and version.该代码适用于具有相同 windows 和版本的其他机器。 However, when I run it in my personal laptop, the plot is not possible to see it:但是,当我在我的个人笔记本电脑上运行它时,plot 是看不到它的:

剧情看不到

I was trying to follow the following info found: help我试图按照找到的以下信息: 帮助

I have run out of ideas, I restarted the laptop, reinstalled jupyter, and nothing seems to work.我的想法已经用完了,我重新启动了笔记本电脑,重新安装了 jupyter,但似乎没有任何效果。 Did anyone have a similar issue?有没有人有类似的问题? Here is the code:这是代码:

    %matplotlib notebook
import matplotlib.pyplot as plt
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgets
import numpy as np
import pandas as pd

def g(qi,d):
    fig = plt.figure()
    x_1 = df['dprod_year']
    y_1 = qi*np.exp(-x_1*d)
    plt.scatter(x_1,y_1,marker='+')
    plt.scatter(df['dprod_year'],df['qoil_1000b'],marker='o',color='grey')
    plt.ylim(0,4000)
    plt.xlim(0,60)
    plt.grid(True,axis='both')
"""
#interact(g,qi=(0.0000,5000,10),d=(0.0000,0.02000,0.0010))
"""
interact(g,qi=widgets.FloatSlider(value=3900,min=0,max=4000,step=10,description='qi:',readout_format='.1f'),
         d=widgets.FloatSlider(value=0.0061,min=0.0001,max=0.01,step=0.001,description='d:',readout_format='.5f'))
plt.show()

Thank you very much for your help.非常感谢您的帮助。

You should try to change from %matplotlib notebook to %matplotlib inline .您应该尝试从%matplotlib notebook更改为%matplotlib inline If that doesn't work then try to restart the kernel.如果这不起作用,请尝试重新启动 kernel。

It seems that in some cases it helps to repeat the setting of the notebook backend, ie try calling it twice like似乎在某些情况下它有助于重复笔记本后端的设置,即尝试调用它两次

%matplotlib notebook
%matplotlib notebook

An analysis for why that is can be found in this comment可以在此评论中找到原因的分析

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM