0

I am following this answer to bring plot windows to the front by choosing a different graphics backend:

Tools > Preferences > Ipython > Graphis > backend 

The options are Inline, Automatic, Qt5, and TKinter. I don't want Inline and I prefer more explicit control than Automatic. Both Qt5 and TKinter pulls the plot window to the front when it is first created, i.e., when the initial plot is done. Here is my test code for creating the plot, adapted from here:

from sklearn import datasets import matplotlib.pyplot as plt digits = datasets.load_digits() data = digits.data from sklearn.manifold import TSNE projection = TSNE().fit_transform(data) plot_kwds = {'alpha' : 0.5, 's' : 80, 'linewidths':1, 'edgecolors':"Blue", 'facecolors':"None"} plt.scatter(*projection.T, **plot_kwds) 

The problem is that if I re-issue the plt.scatter() command (say, with different plot_kwds options), the plot window does not get pulled to the front. I'm going through a quick cycle of re-plots, so it's not efficient to use the mouse to the plot window to the front.

Is there a command (or another way) to will bring the plot window to the front?

1 Answer 1

0

Based on this page, I tried the following.

Works: For the Tk, the following was given. I chose the TKinter backend

cfm = plt.get_current_fig_manager() cfm.window.attributes('-topmost', True) cfm.window.attributes('-topmost', False) 

Didn't work: For Qt, the following was given. I chose the Qt5 backend, but nothing happened. It might work in an environment/setting other than mine.

cfm = plt.get_current_fig_manager() cfm.window.activateWindow() cfm.window.raise_() 

For both, I restarted all kernels with the new backend before replotting and trying to raise the plot window.

Afternote: Sometimes, new plots aren't plotted in a separate figure window. I haven't figured out the cause, but what seems to fix this is to use the Spyder GUI to change the backend to Qt5, plot a figure (which does end up going to a separate window), close the figure, restore the backend to TKinter, and re-plot the figure.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.