当我将pycharm与docker容器一起使用时,如何显示matplotlib图

时间:2018-07-31 20:38:55

标签: docker pycharm

我现在在Docker中使用Pycharm。该代码在Docker容器中运行。现在的问题是,无法显示matplotlib图形。代码放在下面,

import matplotlib
import matplotlib.pyplot as plt
import numpy as np
# Data for plotting
t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2 * np.pi * t)
# Note that using plt.subplots below is equivalent to using
# fig = plt.figure() and then ax = fig.add_subplot(111)
fig, ax = plt.subplots()
ax.plot(t, s)
ax.set(xlabel='time (s)', ylabel='voltage (mV)',
       title='About as simple as it gets, folks')
ax.grid()
fig.savefig("test.png")
plt.show()

代码被发送到docker容器执行。现在,我必须将图形另存为文件,然后将其打开,这非常不方便。 有一些方法可以使pycharm自动显示图形吗? 谢谢。 我正在Ubuntu 16.0.4中使用Pycharm 2018 Professional。

0 个答案:

没有答案