Refresh / refresh matplotlib plots on second monitor

I am currently working with Spyder and doing my plot using matplotlib. I have two monitors, one for development and another for (data) viewing and other things. Since I am doing some calculations and my code changes frequently, I often (re) execute the code and go through the graphs to check if the results are correct.

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

I've already searched for a solution but couldn't find anything. This would be very helpful to 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.

+3


source to share


2 answers


It is related to matplotlib, not Spyder. Placing the location of the shape is clearly one of those things for which workarounds do exist ... see the answers to the question here . This is an old question, but I'm not sure if there have been any changes since then (any matplotlib developers, feel free to correct me!).

The second monitor shouldn't make any difference, it looks like the problem is that the digit is being replaced with a new one.



Fortunately, you can easily update the shapes that you have moved to where you want by easily using the object interface and updating the Axes object without creating a new shape. Below is an example:

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

      

+2


source


I know this is an old question, but I ran into a similar problem and found this question. I was able to move my plots to the second screen using the QT4Agg server.

import matplotlib.pyplot as plt
plt.switch_backend('QT4Agg')

# a little hack to get screen size; from here [1]
mgr = plt.get_current_fig_manager()
mgr.full_screen_toggle()
py = mgr.canvas.height()
px = mgr.canvas.width()
mgr.window.close()
# hack end

x = [i for i in range(0,10)]
plt.figure()
plt.plot(x)

figManager = plt.get_current_fig_manager()
# if px=0, plot will display on 1st screen
figManager.window.move(px, 0)
figManager.window.showMaximized()
figManager.window.setFocus()

plt.show()

      



[1] answer from @divenex: How to set the absolute position of curly windows using matplotlib?

0


source







All Articles