JULIA Plots GR savefig错误

时间:2018-04-17 21:54:21

标签: plot julia

当我第一次使用JUNO在JULIA中运行Plots时 savefig(路径)给出了以下错误。当我第二次运行长模拟时,错误消失。任何线索为什么会发生这种情况?

CODE

Characteristic curve
            gr()
            Plot1= plot(Se, 10.*log10.(H_vg), label= "Vangenuchten")
            plot!(Se, 10.*log10.(H_kg), label= "Kosugi")
            plot!( title= "THETA(h)", xlabel= "Se [-]", ylabel= "log10 h [cm]", linewidth=4)


            # Unsaturated curve
            Plot2= plot(Se, Kr_vg, label= "Vangenuchten")
            plot!(Se, Kr_kg, label= "Kosugi")
            plot!(title= "K(theta)", xlabel= "Se [-]", ylabel= "Kr [-]", linewidth=4)

            #Infiltration
            Infiltration_Inv2= Infiltration_Inv[i_Sample, 1: Infiltration_N[i_Sample]]
            Infiltration2= Infiltration[i_Sample, 1: Infiltration_N[i_Sample]]
            Infiltration_Hydro2 = Infiltration_Hydro[i_Sample, 1: Infiltration_N[i_Sample]]
            T2=  T[i_Sample, 1:Infiltration_N[i_Sample]]
            Plot3= plot(T2, Infiltration2, label= "Observed")
            plot!(T2, Infiltration_Hydro2, label= "Best")
            plot!(T2, Infiltration_Inv2, label= "Simulated")
            plot!(title= "INFILTRATION METHODS", xlabel= "Time [minutes]", ylabel= "Infiltration [mm/minute]", linewidth=4)

            #DθDh
            Plot4= plot(Se, DθDh_kg)
            plot!(title= "Pore Size Distribution", xlabel= "Se", ylabel= "Probality Distribution", linewidth=4)

            plot(Plot1, Plot2, Plot3, Plot4, layout=(4,1))
            savefig(Path)

错误消息

**LoadError: MethodError: no method matching setcharheight(::Float64)**
*The applicable method may be too new: running in world age 22349, while current world is 22350.*
Closest candidates are:
  setcharheight(::Real) at C:\JULIA\pkgs-0.6.2.1\v0.6\GR\src\GR.jl:1071 (method too new to be called from this world context.)
while loading C:\JOE\Main\MODELS\SOIL\BEST\MAIN_BEST.jl, in expression starting on line 260
#gr_set_font#463(::Symbol, ::Symbol, ::ColorTypes.RGBA{Float64}, ::Int64, ::Function, ::Plots.Font) at gr.jl:412
(::Plots.#kw##gr_set_font)(::Array{Any,1}, ::Plots.#gr_set_font, ::Plots.Font) at <missing>:0
gr_set_xticks_font(::Plots.Subplot{Plots.GRBackend}) at gr.jl:605
_update_min_padding!(::Plots.Subplot{Plots.GRBackend}) at gr.jl:654
_collect(::Array{RecipesBase.AbstractLayout,2}, ::Base.Generator{Array{RecipesBase.AbstractLayout,2},Plots.#_update_min_padding!}, ::Base.EltypeUnknown, ::Base.HasShape) at array.jl:488
_update_min_padding!(::Plots.GridLayout) at layouts.jl:310
_collect(::Array{RecipesBase.AbstractLayout,2}, ::Base.Generator{Array{RecipesBase.AbstractLayout,2},Plots.#_update_min_padding!}, ::Base.EltypeUnknown, ::Base.HasShape) at array.jl:488
_update_min_padding!(::Plots.GridLayout) at layouts.jl:310
prepare_output(::Plots.Plot{Plots.GRBackend}) at plot.jl:262
show(::IOStream, ::MIME{Symbol("application/pdf")}, ::Plots.Plot{Plots.GRBackend}) at output.jl:209
pdf(::Plots.Plot{Plots.GRBackend}, ::String) at output.jl:25
savefig(::Plots.Plot{Plots.GRBackend}, ::String) at output.jl:123
BEST_MAIN() at MAIN_BEST.jl:252
include_string(::String, ::String) at loading.jl:522
include_string(::Module, ::String, ::String) at Compat.jl:174
(::Atom.##57#60{String,String})() at eval.jl:74
withpath(::Atom.##57#60{String,String}, ::String) at utils.jl:30
withpath(::Function, ::String) at eval.jl:38
macro expansion at eval.jl:72 [inlined]
(::Atom.##56#59{Dict{String,Any}})() at task.jl:80

1 个答案:

答案 0 :(得分:0)

据我了解,GR后端存在一个错误,它与#34; @eval import#backend&#34;相关联。在Plots代码中,如here所述 现在的解决方法是在使用Plots模块的命令之后使用导入后端的附加行(在您的情况下为GR),类似于下面的代码:

&#13;
&#13;
using Plots
import GR

#your code here
&#13;
&#13;
&#13;