At the Spyder console (the REPL), I issue import matplotlib.pyplot as plt
. It is the topmost namespace, i.e., corresponding to globals()
.
In a Spyder startup file, I define a function to raise figure windows to the top.
def TKraiseCFG( FigID = None ):
import matplotlib.pyplot as plt
% The rest is just context
%-------------------------
plt=globals()['plt']
if FigID is not None: plt.figure( FigID )
cfm = plt.get_current_fig_manager()
cfm.window.attributes('-topmost', True)
cfm.window.attributes('-topmost', False)
return cfm
Does the plt
in TKraiseCFG()
refer to the same object as plt
at the REPL?
Further context (not the main question): I can’t imagine a console/REPL (or even multiple consoles) using more than one matplotlib.pyplot
. But I’m just getting to know Python, so I could be wrong. For the case of a single common matplotlib.pyplot
, however, I’m seeking a way to have it accessible to all scopes so that I can write convenience/utility functions like TKraiseCFG()
(which is just cobbled together after reading various pages, weeks ago). Unfortunately, my current method requires that code invoking TKraiseCFG()
contain a variable specifically named plt
referencing matplotlib.pyplot
.