相关疑难解决方法(0)

使matplotlib绘图窗口弹出为活动窗口

我在mac os x上使用python和matplotlib.当我在许多不同的窗口上工作并且我必须运行一个产生绘图的脚本时,绘图窗口总是在活动窗口后面打开,并且非常沮丧地必须在窗口之间切换以查看图像.是为什么决定绘图窗口的位置,和/或将其弹出为前景窗口?

谢谢

python macos matplotlib

34
推荐指数
3
解决办法
3万
查看次数

Matplotlib Python 窃取屏幕焦点

我的代码正在从 arduino 获取串行数据,对其进行处理,然后对其进行绘图。我使用 matplotlib 作为图形界面。每次它“绘制”时,它都会强迫人们注意它,除此之外,用户将无法看到任何东西。停止这种情况的最佳方法是什么?(除了窃取焦点外,代码工作正常)。在另一篇文章中阅读该方法后,我尝试使用 matplotlib.use('Agg') 方法,但它不起作用。(使用 MAC OS X)。

下面显示的代码是一个超级简单的数据更新图,我也有同样的问题。我没有显示我的代码,因为它在没有正确输入的情况下不可复制粘贴这是我的代码:

import matplotlib
from matplotlib import *
from pylab import *
# import math


x=[]
y=[]
def function(iteration):
    xValue=iteration#Assigns current x value
    yValue=(1./iteration)*34#Assigns current y value

    x.extend([xValue]) #adds the current x value to the x list
    y.extend([yValue]) #adds the current y value to the y list


    clf() #clears the plot

    plot(x,y,color='green') #tells the plot what to do 
    draw() #forces a draw

def main():

    for i in range(1,25): #run my function …
Run Code Online (Sandbox Code Playgroud)

macos graphing focus matplotlib python-2.7

9
推荐指数
1
解决办法
1732
查看次数

如何在后台保持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
查看次数

如何防止 matplotlib 抢走焦点?

我正在循环浏览一堆图像,并且需要在显示每个图像时在终端中输入一个标签,有点像这样:

for pic in pics:
  fig = plt.figure()
  plt.imshow(pic)
  lbl = input()
  ...
  plt.close(fig)
Run Code Online (Sandbox Code Playgroud)

问题是这个数字抢走了焦点,所以我需要先继续点击终端,然后再打字,而不是仅仅打字。这可以避免吗?

python matplotlib

5
推荐指数
1
解决办法
2425
查看次数

标签 统计

matplotlib ×4

python ×3

focus ×2

macos ×2

background ×1

graphing ×1

python-2.7 ×1

window ×1