joshday / OnlineStats.jl

⚡ Single-pass algorithms for statistics
https://joshday.github.io/OnlineStats.jl/latest/
MIT License
831 stars 62 forks source link

Plot of GroupBy of HeatMap fails #277

Closed schlichtanders closed 3 months ago

schlichtanders commented 6 months ago

Here a minimal failing example

using DataFrames, CSV, OnlineStats, Plots
url = "https://raw.githubusercontent.com/mwaskom/seaborn-data/master/iris.csv"
df = DataFrame(CSV.File(download(url)))
o = GroupBy(String, HeatMap(4:0.25:8, 2:0.25:4.5))
res = mapreduce(r -> (String(r.species), (r.sepal_length, r.sepal_width)), fit!, eachrow(df), init=o)
plot(res)

fails with

julia> plot(res)
ERROR: Cannot convert @NamedTuple{x::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, y::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, z::Matrix{Int64}} to series data for plotting
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:35
[2] _prepare_series_data(x::@NamedTuple{x::StepRangeLen{…}, y::StepRangeLen{…}, z::Matrix{…}})
@ RecipesPipeline ~/.julia/packages/RecipesPipeline/BGM3l/src/series.jl:8
[3] _series_data_vector(x::@NamedTuple{x::StepRangeLen{…}, y::StepRangeLen{…}, z::Matrix{…}}, plotattributes::Dict{Symbol, Any})
@ RecipesPipeline ~/.julia/packages/RecipesPipeline/BGM3l/src/series.jl:36
[4] (::RecipesPipeline.var"#21#24"{Dict{…}})(vi::@NamedTuple{x::StepRangeLen{…}, y::StepRangeLen{…}, z::Matrix{…}})
@ RecipesPipeline ./none:0
[5] iterate
@ ./generator.jl:47 [inlined]
[6] _series_data_vector(v::Vector{@NamedTuple{…}}, plotattributes::Dict{Symbol, Any})
@ RecipesPipeline ~/.julia/packages/RecipesPipeline/BGM3l/src/series.jl:51
[7] macro expansion
@ ~/.julia/packages/RecipesPipeline/BGM3l/src/series.jl:129 [inlined]
[8] apply_recipe(plotattributes::AbstractDict{Symbol, Any}, ::Type{RecipesPipeline.SliceIt}, x::Any, y::Any, z::Any)
@ RecipesPipeline ~/.julia/packages/RecipesBase/BRe07/src/RecipesBase.jl:300
[9] _process_userrecipes!(plt::Any, plotattributes::Any, args::Any)
@ RecipesPipeline ~/.julia/packages/RecipesPipeline/BGM3l/src/user_recipe.jl:38
[10] recipe_pipeline!(plt::Any, plotattributes::Any, args::Any)
@ RecipesPipeline ~/.julia/packages/RecipesPipeline/BGM3l/src/RecipesPipeline.jl:72
[11] _plot!(plt::Plots.Plot, plotattributes::Any, args::Any)
@ Plots ~/.julia/packages/Plots/HyyIK/src/plot.jl:223
[12] #plot#188
@ ~/.julia/packages/Plots/HyyIK/src/plot.jl:102 [inlined]
[13] plot(args::Any)
@ Plots ~/.julia/packages/Plots/HyyIK/src/plot.jl:93
[14] top-level scope
@ REPL[107]:1
joshday commented 3 months ago

Fixed on master! Release coming soon.