@@ -36,8 +36,11 @@ def get_backend_name(name=None):
36
36
return backend_name
37
37
38
38
39
- def get_backend ():
40
- backend_name = get_backend_name ()
39
+ def get_backend (name = None ):
40
+ # Import the requested backend into a generic module object
41
+ # the last argument is specifies whether to use absolute or relative
42
+ # imports. 0 means only perform absolute imports.
43
+ backend_name = get_backend_name (name )
41
44
return __import__ (backend_name , globals (), locals (),
42
45
[backend_name ], 0 )
43
46
@@ -70,18 +73,23 @@ def pylab_setup(name=None):
70
73
71
74
'''
72
75
# Import the requested backend into a generic module object
73
- backend_name = get_backend_name (name )
74
- # the last argument is specifies whether to use absolute or relative
75
- # imports. 0 means only perform absolute imports.
76
- backend_mod = __import__ (backend_name , globals (), locals (),
77
- [backend_name ], 0 )
76
+ backend_mod = get_backend (name )
78
77
79
78
# Things we pull in from all backends
80
79
new_figure_manager = backend_mod .new_figure_manager
81
80
82
81
# image backends like pdf, agg or svg do not need to do anything
83
82
# for "show" or "draw_if_interactive", so if they are not defined
84
83
# by the backend, just do nothing
84
+ def do_nothing_show (* args , ** kwargs ):
85
+ frame = inspect .currentframe ()
86
+ fname = frame .f_back .f_code .co_filename
87
+ if fname in ('<stdin>' , '<ipython console>' ):
88
+ warnings .warn ("""
89
+ Your currently selected backend, '%s' does not support show().
90
+ Please select a GUI backend in your matplotlibrc file ('%s')
91
+ or with matplotlib.use()""" %
92
+ (backend , matplotlib .matplotlib_fname ()))
85
93
86
94
def do_nothing (* args , ** kwargs ):
87
95
pass
@@ -101,13 +109,3 @@ def do_nothing(*args, **kwargs):
101
109
global backend
102
110
backend = name
103
111
return backend_mod , new_figure_manager , draw_if_interactive , show
104
-
105
- def do_nothing_show (* args , ** kwargs ):
106
- frame = inspect .currentframe ()
107
- fname = frame .f_back .f_code .co_filename
108
- if fname in ('<stdin>' , '<ipython console>' ):
109
- warnings .warn ("""
110
- Your currently selected backend, '%s' does not support show().
111
- Please select a GUI backend in your matplotlibrc file ('%s')
112
- or with matplotlib.use()""" %
113
- (name , matplotlib .matplotlib_fname ()))
0 commit comments