当尝试使用 pyplot 在 jupyter 上绘制图形时,我正在运行以下代码:
import matplotlib.pyplot as plt
plt.plot([1,2,3,4])
plt.ylabel('some numbers')
plt.show()
Run Code Online (Sandbox Code Playgroud)
这将返回以下错误:
AttributeError Traceback (most recent call last)
<ipython-input-16-51b004b519a9> in <module>()
----> 1 get_ipython().run_line_magic('matplotlib', 'inline')
2
3
4 import matplotlib.pyplot as plt
5 plt.plot([1,2,3,4])
c:\program files (x86)\microsoft visual studio\shared\python36_64\lib\site-packages\IPython\core\interactiveshell.py in run_line_magic(self, magic_name, line, _stack_depth)
2129 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
2130 with self.builtin_trap:
-> 2131 result = fn(*args,**kwargs)
2132 return result
2133
<decorator-gen-108> in matplotlib(self, line)
c:\program files (x86)\microsoft visual studio\shared\python36_64\lib\site-packages\IPython\core\magic.py in <lambda>(f, *a, **k)
185 # but it's overkill …Run Code Online (Sandbox Code Playgroud)