Matplotlib figure placement on screen

I have a script which plots several workspaces of results, now using matplotlib. By default every new plot window is positioned exactly centrally on the screen so they all stack up. How do I make it distribute them sensibly? I’ve not yet found any optional arguments I can give to plt.subplots() or fig.show() which might help. Or should this be something that Mantid organises? The same “exact central” rule applies to plots made by right clicking on workspaces and “Plot spectrum” etc.

In this case it’s not particularly appropriate to make a big plot window with N small subplots in it (which would sometimes be a useful option).

I’ve put a little script together that should be a rather simple solve for this! the key line here being fig.canvas.manager.wnidow.move(a,b)
I think the coordinates work as where the top,left corner of the Figure is on the screen from the top left of the screen, seems to work for dual monitors as well!

from __future__ import (absolute_import, division, print_function, unicode_literals)
from mantid.simpleapi import *
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.figure import Figure

# Create a workspace that has a Gaussian peak
x = np.arange(20)
y0 = 10.+50*np.exp(-(x-10)**2/20)

 for i in range(4):
    fig, ax = plt.subplots(subplot_kw={'projection':'mantid'})
    ax.plot(x,y0) # plot the initial guess with black line

figs = list(map(plt.figure, plt.get_fignums()))   

a = 2000
b = 500

figs[0].canvas.manager.window.move(0,0)
figs[1].canvas.manager.window.move(a,0)
figs[2].canvas.manager.window.move(0,b)
figs[3].canvas.manager.window.move(a,b)

for i in range(4):
    figs[i].show()

Thanks. Works for me. I made my script do fig.canvas.manager.window.move() and fig.show() as I generate the plots so they appear one at a time in a diagonal row just like MantidPlot.
Is there any documentation, if for example I want to space the windows across the available monitor(s)? Searching the matplotlib web pages hasn’t turned up anything useful yet.

I’m not aware of any documnetation that’s overly helpful. The best thing I found was this: python - How do you set the absolute position of figure windows with matplotlib? - Stack Overflow
But they talk about using differrent backends like WX (pretty sure we’re using Qt5) so lots of this page is unhelpful.

For me setting a large enough coordinate (such as a = 2000) sets the plot on my second screen! Is this the case for you. One of the nicer parts of that link I’ve attached shows a function they’ve defined so that could be the sort of thing you’re going for?? But again they’ve not done it in the fig.canvas.manager.window.move() manner, which is the simplest way in Workbench

I’ve got my “primary” screen on the right so I find that negative x coordinates put the windows on the second (left) screen. Slightly negative coordinates overlap the join. Extreme values send the window way off into virtual screen space: it’s possible to find it on the task bar and maximise it and thereby make it visible/usable again.
Should Mantid/matplotlib have a better default policy than “all the windows in a neat stack in the middle”, where the user/script doesn’t specify coordinates? For example “cascade” like MantidPlot (QTI) windows do, or I might choose on a 2 monitor system to put the graph windows on whichever monitor doesn’t have the main Mantid window or any active Interfaces?

I’ve have created an issue and we will consider these options for future development. Figure Window Placement · Issue #27599 · mantidproject/mantid · GitHub