@@ -143,8 +143,8 @@ function find_backend(matplotlib::PyObject)
143143 end
144144 end
145145 if pyexists (" matplotlib.backends.backend_" * lowercase (b))
146- isjulia_display[1 ] || pygui_start (g)
147- matplotlib." interactive" (! isjulia_display[1 ] && Base. isinteractive ())
146+ isjulia_display[] || pygui_start (g)
147+ matplotlib." interactive" (! isjulia_display[] && Base. isinteractive ())
148148 return (b, g)
149149 end
150150 end
@@ -156,14 +156,14 @@ function find_backend(matplotlib::PyObject)
156156 if (gui== :qt && ! PyCall. pyexists (" PyQt5" ) && ! PyCall. pyexists (" PyQt4" )) || gui== :qt_pyside
157157 rcParams." backend.qt4" = " PySide"
158158 end
159- isjulia_display[1 ] || pygui_start (gui)
160- matplotlib." interactive" (! isjulia_display[1 ] && Base. isinteractive ())
159+ isjulia_display[] || pygui_start (gui)
160+ matplotlib." interactive" (! isjulia_display[] && Base. isinteractive ())
161161 return (gui2matplotlib[gui], gui)
162162 end
163163 catch e
164- if ! isjulia_display[1 ]
164+ if ! isjulia_display[]
165165 @warn (" No working GUI backend found for matplotlib" )
166- isjulia_display[1 ] = true
166+ isjulia_display[] = true
167167 end
168168 pygui (:default )
169169 matplotlib." use" (" Agg" ) # GUI not available
@@ -172,10 +172,16 @@ function find_backend(matplotlib::PyObject)
172172 end
173173end
174174
175+ # declare more globals created in __init__
176+ const isjulia_display = Ref (true )
177+ version = v " 0.0.0"
178+ backend = " Agg"
179+ gui = :default
180+
175181# initialization -- anything that depends on Python has to go here,
176182# so that it occurs at runtime (while the rest of PyPlot can be precompiled).
177183function __init__ ()
178- global isjulia_display = Bool[ isdisplayok ()]
184+ isjulia_display[] = isdisplayok ()
179185 copy! (matplotlib, pyimport_conda (" matplotlib" , " matplotlib" ))
180186 mvers = matplotlib. __version__
181187 global version = try
@@ -208,7 +214,7 @@ function __init__()
208214 Main. IJulia. push_posterror_hook (close_figs)
209215 end
210216
211- if isjulia_display[1 ] && gui != :gr && backend != " Agg"
217+ if isjulia_display[] && gui != :gr && backend != " Agg"
212218 plt." switch_backend" (" Agg" )
213219 plt." ioff" ()
214220 end
@@ -217,7 +223,7 @@ function __init__()
217223end
218224
219225function pygui (b:: Bool )
220- if ! b != isjulia_display[1 ]
226+ if ! b != isjulia_display[]
221227 if backend != " Agg"
222228 plt." switch_backend" (b ? backend : " Agg" )
223229 if b
@@ -229,7 +235,7 @@ function pygui(b::Bool)
229235 elseif b
230236 error (" No working GUI backend found for matplotlib." )
231237 end
232- isjulia_display[1 ] = ! b
238+ isjulia_display[] = ! b
233239 end
234240 return b
235241end
0 commit comments