小编mbr*_*nwa的帖子

如何在后台保持matplotlib(python)窗口?

我有一个python/matplotlib应用程序,经常使用来自测量仪器的新数据更新绘图.使用新数据更新绘图时,绘图窗口不应相对于桌面上的其他窗口从背景更改为前景(反之亦然).

这在运行Ubuntu 16.10和matplotlib 1.5.2rc的机器上运行Python 3.但是,在使用Ubuntu 17.04和matplotlib 2.0.0的其他计算机上,每次使用新数据更新绘图时,图形窗口会弹出到前面.

在使用新数据更新绘图时,如何控制窗口前景/背景行为并保持窗口焦点?

这是一个代码示例,说明了我的绘图例程:

import matplotlib
import matplotlib.pyplot as plt
from time import time
from random import random

print ( matplotlib.__version__ )

# set up the figure
fig = plt.figure()
plt.xlabel('Time')
plt.ylabel('Value')
plt.ion()

# plot things while new data is generated:
t0 = time()
t = []
y = []
while True:
    t.append( time()-t0 )
    y.append( random() )
    fig.clear()
    plt.plot( t , y )
    plt.pause(1)
Run Code Online (Sandbox Code Playgroud)

python background focus window matplotlib

8
推荐指数
1
解决办法
4302
查看次数

标签 统计

background ×1

focus ×1

matplotlib ×1

python ×1

window ×1