StatsPlots.jl icon indicating copy to clipboard operation
StatsPlots.jl copied to clipboard

@df macro MethodError Symbol not callable

Open eddieschoute opened this issue 4 years ago • 2 comments

I'm encountering a strange error when using @df that I don't understand but I made a MWE.

df = DataFrame(a = 1:10, b = 10 .* rand(10), c = 10 .* rand(10), d = rand(10), name = "yes", series = "a")
append!(df, DataFrame(a = 1:10, b = 10 .* rand(10), c = 10 .* rand(10), d = rand(10), name = "no", series = "a"))
append!(df, DataFrame(a = 1:10, b = 10 .* rand(10), c = 10 .* rand(10), d = rand(10), name = "no", series = "b"))
append!(df, DataFrame(a = 1:10, b = 10 .* rand(10), c = 10 .* rand(10), d = rand(10), name = "no", series = "b"))

@df df plot(
    :a,
    :b,
    ribbon = :d,
    group = (:name, :series),
    colour = [:red :green],
    legendtitle = "legend title",
    axis = :log,
    ylabel = "ylabel",
    xlabel = "xlabel",
    xlim = (3, 12),
    title = "title",
    legend = :outertopright,
    size = (1000, 600),
)

This gives me the exception

ERROR: LoadError: MethodError: objects of type Symbol are not callable
Stacktrace:
 [1] add_label(::String, ::Symbol, ::Array{Int64,1}, ::Vararg{Any,N} where N; kwargs::Base.Iterators.Pairs{Symbol,Any,NTuple{11,Symbol},NamedTuple{(:ribbon, :group, :colour, :legendtitle, :axis, :ylabel, :xlabel, :xlim, :title, :legend, :size),Tuple{Array{Float64,1},Tuple{Array{String,1},Array{String,1}},Array{Symbol,2},String,Symbol,String,String,Tuple{Int64,Int64},String,Symbol,Tuple{Int64,Int64}}}}) at C:\Users\eddie\.julia\packages\StatsPlots\y1j3G\src\df.jl:153
 [2] (::var"#283#284")(::DataFrame) at .\none:0
 [3] top-level scope at e:\xxx\script.jl:6
in expression starting at e:\xxx\script.jl:6

Now, I've tried to remove any of the above options to plot, but it will no longer give an error. Even removing the seemingly unrelated title or size will fix the issue. What is happening here?

eddieschoute avatar Apr 12 '21 20:04 eddieschoute

I wasn't able to reproduce this. @eddieschoute if you update StatsPlots, do you still get this error?

sethaxen avatar Jul 07 '21 23:07 sethaxen

I just tried on a fresh computer and also could not reproduce. I'll try it on the old device as well but hopefully it resolved itself.

eddieschoute avatar Jul 13 '21 20:07 eddieschoute