Merge pull request #1838 from tkf/smuggle

Smuggle PyCall and LaTeXStrings through PyPlot
This commit is contained in:
Michael Krabbe Borregaard 2018-11-09 08:20:55 +01:00 committed by GitHub
commit 3bfedd844e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 23 deletions

View File

@ -526,8 +526,7 @@ const _plotlyjs_scale = _plotly_scale
function _initialize_backend(::PyPlotBackend) function _initialize_backend(::PyPlotBackend)
@eval Main begin @eval Main begin
import PyPlot, PyCall import PyPlot
import LaTeXStrings
export PyPlot export PyPlot
@ -539,11 +538,8 @@ end
function add_backend_string(::PyPlotBackend) function add_backend_string(::PyPlotBackend)
""" """
using Pkg using Pkg
Pkg.add("PyPlot")
Pkg.add("PyCall")
Pkg.add("LaTeXStrings")
withenv("PYTHON" => "") do withenv("PYTHON" => "") do
Pkg.build("PyCall") Pkg.add("PyPlot")
Pkg.build("PyPlot") Pkg.build("PyPlot")
end end
""" """

View File

@ -1,3 +1,6 @@
# Do "using PyPlot: PyCall, LaTeXStrings" without dependency warning:
const PyCall = PyPlot.PyCall
const LaTeXStrings = PyPlot.LaTeXStrings
# https://github.com/stevengj/PyPlot.jl # https://github.com/stevengj/PyPlot.jl
@ -187,7 +190,6 @@ function add_pyfixedformatter(cbar, vals::AVec)
cbar[:update_ticks]() cbar[:update_ticks]()
end end
@require LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" begin
function labelfunc(scale::Symbol, backend::PyPlotBackend) function labelfunc(scale::Symbol, backend::PyPlotBackend)
if scale == :log10 if scale == :log10
x -> LaTeXStrings.latexstring("10^{$x}") x -> LaTeXStrings.latexstring("10^{$x}")
@ -199,15 +201,12 @@ end
string string
end end
end end
end
@require PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0" begin
function py_mask_nans(z) function py_mask_nans(z)
# pynp["ma"][:masked_invalid](z))) # pynp["ma"][:masked_invalid](z)))
PyCall.pycall(pynp["ma"][:masked_invalid], Any, z) PyCall.pycall(pynp["ma"][:masked_invalid], Any, z)
# pynp["ma"][:masked_where](pynp["isnan"](z),z) # pynp["ma"][:masked_where](pynp["isnan"](z),z)
end end
end
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------