在第二台显示器上更新/刷新 matplotlib 图 [英] Update/Refresh matplotlib plots on second monitor

查看:90
本文介绍了在第二台显示器上更新/刷新 matplotlib 图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我正在使用Spyder并使用matplotlib进行绘图.我有两个监视器,一个用于开发,另一个用于(数据)浏览和其他内容.由于我正在做一些计算并且我的代码经常更改,我经常(重新)执行代码并查看图表以检查结果是否有效.

At the moment I am working with Spyder and doing my plotting with matplotlib. I have two monitors, one for development and another for (data) browsing and other stuff. Since I am doing some calculations and my code often changes, I often (re)execute the code and have a look at the plots to check if the results are valid.

有什么办法可以将我的 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!

以下是一些其他信息:

操作系统:Ubuntu 14.04(64 位)Spyder 版本:2.3.2Matplotlib版本:1.3.1.-1.4.2.

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

推荐答案

这与 matplotlib 相关,与 Spyder 无关.明确地放置图形的位置似乎只是其中一种解决方法……请参阅问题的答案

This has to do with matplotlib, not Spyder. Placing the location of a figure explicitly appears to be one of those things for which there's really just workarounds ... see the answers to the question here. That's an old question, but I'm not sure there's been change since then (any matplotlib devs, feel free to correct me!).

第二台显示器应该没有任何区别,听起来问题只是这个数字被一个新的取代了.

The second monitor shouldn't make any difference, it sounds like the issue is just that the figure is being replaced with a new one.

幸运的是,您可以非常轻松地更新已移动到所需位置的图形,方法是专门使用对象界面,并在不创建新图形的情况下更新 Axes 对象.示例如下:

Fortunately you can update figures you've moved to where you want them pretty easily, by using the object interface specifically, and updating the Axes object without creating a new figure. An example is below:

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()

这篇关于在第二台显示器上更新/刷新 matplotlib 图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆