-3
由于实际的原因,我想测试一下repl.it上的一小段Pyton代码(基于web的,因此我不需要安装Python)。为什么不能在repl.it上使用Python绘图
代码
import numpy as np
import matplotlib.pyplot as plt
time = np.array([0, 1, 2, 3])
vec = np.array([1, 4, 3, -2])
plt.plot(time, vec)
给出了以下错误:
[GCC 4.8.2] on linux
Traceback (most recent call last):
File "main.py", line 16, in <module>
plt.figure()
File "/goval_modules/python35/matplotlib/pyplot.py", line 535, in figure
**kwargs)
File "/goval_modules/python35/matplotlib/backends/backend_tkagg.py", line 84, in new_figure_manager
return new_figure_manager_given_figure(num, figure)
File "/goval_modules/python35/matplotlib/backends/backend_tkagg.py", line 92, in new_figure_manager_given_figure
window = Tk.Tk()
File "/usr/local/lib/python3.5/tkinter/__init__.py", line 1868, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable
exited with non-zero status
这是什么意思?
由于在线网站没有GUI服务器来显示图表。 –
@MartijnPieters好的,有什么方法可以显示或下载剧情? – Karlo
你可以在[try.jupyter.org](https://try.jupyter.org)运行你的代码,在那里你得到一些内联(即png)输出。 – ImportanceOfBeingErnest