From 87627b8320718704fc5157b7b4605b47d9f4cc1d Mon Sep 17 00:00:00 2001 From: Morten Piibeleht Date: Thu, 16 Aug 2018 11:03:21 +1200 Subject: [PATCH 1/2] Wrap latexstring use in an at-require latexstring comes from the LaTeXStrings package, which is conditionally loaded by pyplot(). Fix #1659. --- src/backends/pyplot.jl | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index e6ac252c..d31a2b6e 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -236,16 +236,17 @@ function add_pyfixedformatter(cbar, vals::AVec) cbar[:update_ticks]() end - -function labelfunc(scale::Symbol, backend::PyPlotBackend) - if scale == :log10 - x -> latexstring("10^{$x}") - elseif scale == :log2 - x -> latexstring("2^{$x}") - elseif scale == :ln - x -> latexstring("e^{$x}") - else - string +@require LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" begin + function labelfunc(scale::Symbol, backend::PyPlotBackend) + if scale == :log10 + x -> LaTeXStrings.latexstring("10^{$x}") + elseif scale == :log2 + x -> LaTeXStrings.latexstring("2^{$x}") + elseif scale == :ln + x -> LaTeXStrings.latexstring("e^{$x}") + else + string + end end end From 47d8aa871b968b64d8517860cf0e41e2f572fd8f Mon Sep 17 00:00:00 2001 From: Morten Piibeleht Date: Thu, 16 Aug 2018 11:05:39 +1200 Subject: [PATCH 2/2] Do not import latexstring into the global scope It will not be visible to functions in Plots anyway. Instead, labelfunc now explicitly specifies that it uses LaTeXStrings.latexstring. --- src/backends.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backends.jl b/src/backends.jl index d6dc3bea..6a5dea31 100644 --- a/src/backends.jl +++ b/src/backends.jl @@ -387,7 +387,7 @@ end function _initialize_backend(::PyPlotBackend) @eval Main begin import PyPlot, PyCall - import LaTeXStrings: latexstring + import LaTeXStrings export PyPlot