Skip to content

Commit 485c002

Browse files
committed
__init__ with copy! and PyNull()
1 parent c60a406 commit 485c002

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/init.jl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
1+
# On `PyNull()` and `copy!`:
2+
# https://github.com/JuliaPy/PyCall.jl/issues/699#issuecomment-504616552
3+
14
"""
25
Matplotlib's style settings [1]. Note that directly editing `mpl.rcParams` has no effect
36
[2]. Editing this object however does work.
47
58
- [1] https://matplotlib.org/stable/tutorials/introductory/customizing.html#the-default-matplotlibrc-file
69
- [2] https://github.com/JuliaPy/PyPlot.jl#modifying-matplotlibrcparams
710
"""
8-
rcParams = nothing
11+
const rcParams = PyNull()
912

1013
"""
1114
A copy of the initial `mpl.rcParams`. Note that we do not use `mpl.rcParamsDefault` or
1215
`mpl.rcParamsOrig`, as these are different to what's actually used by default (e.g. in a
1316
Jupyter notebook).
1417
"""
15-
rcParams_original = nothing
18+
const rcParams_original = PyNull()
1619

1720
function __init__()
18-
global rcParams_original = copy(mpl.rcParams)
19-
global rcParams = PyPlot.PyDict(mpl."rcParams") # String quotes prevent conversion from
20-
# Python to Julia dict.
21+
copy!(rcParams_original, mpl.rcParams)
22+
copy!(rcParams, PyPlot.PyDict(mpl."rcParams")) # String quotes prevent conversion from
23+
# # Python to Julia dict.
2124
set_mpl_style!(sciplotlib_style)
2225
end

0 commit comments

Comments
 (0)