When using GR from Juno, via test_examples or in a file, there's appeared a world age issue. The error message cites setcharheight in the gr_set_font function: https://github.com/JuliaPlots/Plots.jl/blob/master/src/backends/gr.jl#L372
By trying out earlier commits it appears that the problem was created by this PR: https://github.com/JuliaPlots/Plots.jl/pull/1038 which does call the gr_set_font function in a different location, but it is not transparent to me why it invokes this issue.
What are the exact steps to reproduce this? I actually get a different world age issue:
no method matching emergencyclosegks()
That was the world age issue earlier - that should be resolved by #808
Just open Juno, using Plots; plot(randn(100), randn(100))
Typo, it was #808 . Edited above.
On Saturday, I could re-produce the world age issue with gr, right now (with d5b455b), it works fine!?!?!?
But I can observe, that (in Jupyter or Atom) a GKSTerm is opened and then immediately closed before the first plot, which should not happen (and does not in GR).
Yes, I just tried it out and can confirm this on my Mac. Ah, that @eval is really playing tricks on us.
I'm not sure what is causing this either, but perhaps the following information might help someone else. I'm running Julia v0.6.0 on Ubuntu 14.04 LTS, with Plots 0.13.1 and GR 0.24.0. The following code pasted into the REPL works perfectly:
using Plots
function f1()
gr()
plot(randn(10), randn(10))
end
f1()
function f2()
gr()
savefig(plot(randn(10), randn(10)), "/home/colin/Temp/tempplot1.svg")
end
f2()
But if I restart julia and run the following:
using Plots
function f2()
gr()
savefig(plot(randn(10), randn(10)), "/home/colin/Temp/tempplot1.svg")
end
f2()
I get the following error:
ERROR: MethodError: no method matching setcharheight(::Float64)
The applicable method may be too new: running in world age 24064, while current world is 24065.
Closest candidates are:
setcharheight(::Real) at /home/colin/.julia/v0.6/GR/src/GR.jl:1063 (method too new to be called from this world context.)
Stacktrace:
[1] #gr_set_font#316(::Symbol, ::Symbol, ::ColorTypes.RGB{FixedPointNumbers.Normed{UInt8,8}}, ::Int64, ::Function, ::Plots.Font) at /home/colin/.julia/v0.6/Plots/src/backends/gr.jl:374
[2] (::Plots.#kw##gr_set_font)(::Array{Any,1}, ::Plots.#gr_set_font, ::Plots.Font) at ./:0
[3] gr_set_xticks_font(::Plots.Subplot{Plots.GRBackend}) at /home/colin/.julia/v0.6/Plots/src/backends/gr.jl:561
[4] _update_min_padding!(::Plots.Subplot{Plots.GRBackend}) at /home/colin/.julia/v0.6/Plots/src/backends/gr.jl:612
[5] _collect(::Array{RecipesBase.AbstractLayout,2}, ::Base.Generator{Array{RecipesBase.AbstractLayout,2},Plots.#_update_min_padding!}, ::Base.EltypeUnknown, ::Base.HasShape) at ./array.jl:454
[6] _update_min_padding!(::Plots.GridLayout) at /home/colin/.julia/v0.6/Plots/src/layouts.jl:310
[7] prepare_output(::Plots.Plot{Plots.GRBackend}) at /home/colin/.julia/v0.6/Plots/src/plot.jl:258
[8] show(::IOStream, ::MIME{Symbol("image/svg+xml")}, ::Plots.Plot{Plots.GRBackend}) at /home/colin/.julia/v0.6/Plots/src/output.jl:207
[9] svg(::Plots.Plot{Plots.GRBackend}, ::String) at /home/colin/.julia/v0.6/Plots/src/output.jl:16
[10] savefig(::Plots.Plot{Plots.GRBackend}, ::String) at /home/colin/.julia/v0.6/Plots/src/output.jl:123
[11] f2() at ./REPL[2]:3
So somehow the call to savefig is triggering it on my machine, but only if I haven't already performed a plot in a different function...
Here is an example that causes (and fixes) the world age error when using Plots in a script. This is on OS X using Julia 0.6.2 with the current master branch of Plots.
using Plots
# import GR # commented results in world age error; uncommented works
function testplot()
gr()
plot(randn(100), randn(100))
savefig("output.png")
end
testplot()
The same example also serves if you switch out gr() for the pyplot() backend: toggling import PyPlot causes/removes the error.
Yes that makes sense - the world age error is caused by @eval import $backend in Plots' code.
Most helpful comment
Here is an example that causes (and fixes) the world age error when using
Plotsin a script. This is on OS X using Julia 0.6.2 with the current master branch of Plots.The same example also serves if you switch out
gr()for thepyplot()backend: togglingimport PyPlotcauses/removes the error.