【问题标题】:JULIA Plots GR savefig errorJULIA 绘制 GR savefig 错误
【发布时间】:2018-09-28 00:12:14
【问题描述】:

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

代码

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

【问题讨论】:

    标签: plot julia


    【解决方案1】:

    据我了解,GR 后端存在一个错误,其根源与 Plots 代码中的“@eval import #backend”相关,如here 所述。
    现在的解决方法是在使用 Plots 模块的命令后使用额外的行导入后端,在您的情况下为 GR,类似于以下代码:

    using Plots
    import GR
    
    #your code here

    【讨论】:

      猜你喜欢
      • 2022-12-11
      • 2021-11-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-30
      • 2011-12-15
      相关资源
      最近更新 更多