StatsPlots.jl
StatsPlots.jl copied to clipboard
corrplot should accept 1d column vector of symbols
using StatsPlots, DataFrames, Statistics
e = DataFrame(rand(1:4,100,3))
@df e corrplot([:x1 :x2]) # ok
works, but this does not
@df e corrplot([:x1,:x2]) # not ok
ERROR: MethodError: no method matching zero(::Type{Array{Int64,1}})
Types are
julia> typeof([:x1,:x2])
Array{Symbol,1}
julia> typeof([:x1 :x2])
Array{Symbol,2}
Confer with
aggregate(e, [:x1,:x2], mean)
that works, but
aggregate(e, [:x1 :x2], mean)
ERROR: MethodError: no method matching aggregate(::DataFrame, ::Array{Symbol,2}, ::typeof(mean))
🤔
That's because StatsPlots is an extension to Plots, which always uses 1-row matrices for passing several series. The other syntax is from the DataFrames package (StatsPlots accepts any Table type). Are you a new StatsPlots user?
I started evaluating StatsPlots. Have to admit it took some time to figure the syntax after having used aggregate from DataFrames.
Yeah, I can see that. We'd just also be hesitant to change that syntax, as it is the central idea of all of the Plots system.
I'd say that it's the first time I've heard that parallel - why would you expect it to use the same syntax as aggregate
?
Seems I am not the only one https://github.com/JuliaPlots/StatsPlots.jl/issues/179
I was expecting to just list the columns, but turns out I was not reading the README.md carefully enough. In summary, a better error message would have been helpful for me.
Fair point!