在第二台显示器上更新/刷新 matplotlib 图

Cor*_*yer 5 python matplotlib scientific-computing spyder

目前我正在与 Spyder 合作并使用 matplotlib 进行绘图。我有两台显示器,一台用于开发,另一台用于(数据)浏览和其他东西。由于我正在进行一些计算并且我的代码经常更改,因此我经常(重新)执行代码并查看图表以检查结果是否有效。

Is there any way to place my matplotlib plots on a second monitor and refresh them from the main monitor?

I have already searched for a solution but could not find anything. It would be really helpful for me!

Here's some additional information:

OS: Ubuntu 14.04 (64 Bit) Spyder-Version: 2.3.2 Matplotlib-Version: 1.3.1.-1.4.2.

Aje*_*ean 2

这与 matplotlib 有关,而不是 Spyder。明确放置图形的位置似乎是实际上只有解决方法的事情之一......请参阅此处问题的答案。这是一个老问题,但我不确定从那时起是否发生了变化(任何 matplotlib 开发人员,请随时纠正我!)。

第二台显示器应该没有任何区别,听起来问题只是该人物被替换为新的。

幸运的是,您可以通过专门使用对象接口轻松更新已移至所需位置的图形,并更新 Axes 对象而无需创建新图形。示例如下:

import matplotlib.pyplot as plt
import numpy as np

# Create the figure and axes, keeping the object references
fig = plt.figure()
ax = fig.add_subplot(111)

p, = ax.plot(np.linspace(0,1))

# First display
plt.show()

 # Some time to let you look at the result and move/resize the figure
plt.pause(3)

# Replace the contents of the Axes without making a new window
ax.cla()
p, = ax.plot(2*np.linspace(0,1)**2)

# Since the figure is shown already, use draw() to update the display
plt.draw()
plt.pause(3)

# Or you can get really fancy and simply replace the data in the plot
p.set_data(np.linspace(-1,1), 10*np.linspace(-1,1)**3)
ax.set_xlim(-1,1)
ax.set_ylim(-1,1)

plt.draw()
Run Code Online (Sandbox Code Playgroud)