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

Missing data leads to MethodError

Open haberdashPI opened this issue 3 years ago • 1 comments

I'm seeing a ~~strange~~ bug ~~that I don't quite understand~~ on AoG 0.6.0:

This code runs successfully

show_decades = (4,5,6,7)
plotdf = subset(plotdf, :decade => ByRow(∈(show_decades)))
plt = mapping(:percent, :mean; color=:dataset, layout=:decade => x -> string("$(10x) - $(10(x+1))")) *
      ((data(subset(plotdf, :measure => ByRow(==("model")))) * 
       mapping(lower=:mean_lower, upper=:mean_upper, group=:measure) *
       visual(LinesFill)) +
      (data(subset(plotdf, :measure => ByRow(==("ground_truth")))) * 
       mapping(group=:measure) *
       visual(Lines, linestyle=:dash)))
save(joinpath(plotdir, "mean_byage_timeline.png"), draw(plt; figure = (; resolution=(1800, 1600))))

But if you change one line:

show_decades = (2,3,4,5,6,7)

Update: you can also change the line to

show_decades = (3,)

This appears to be about the missing value in mean_lower, mean_upper.

It now throws an error:

ERROR: MethodError: no method matching color(::Observable{Any})
Closest candidates are:
  color(::Color) at ~/.julia/packages/ColorTypes/6m8P7/src/traits.jl:108
  color(::TransparentColor{C, T, 2} where T) where C at ~/.julia/packages/ColorTypes/6m8P7/src/traits.jl:109
  color(::TransparentColor{C, T, 3} where T) where C at ~/.julia/packages/ColorTypes/6m8P7/src/traits.jl:110
  ...
Stacktrace:
  [1] convert_attribute(c::Tuple{Observable{Any}, Float64}, k::MakieCore.Key{:color})
    @ Makie ~/.julia/packages/Makie/gQOQF/src/conversions.jl:752
  [2] to_color(color::Tuple{Observable{Any}, Float64})
    @ Makie ~/.julia/packages/Makie/gQOQF/src/conversions.jl:700
  [3] legend_elements(::Type{Combined{AlgebraOfGraphics.linesfill}}; color::Observable{Any}, fillalpha::Float64, kwargs::Base.Pairs{Symbol, Int64, Tuple{Symbol}, NamedTuple{(:upper,), Tuple{Int64}}})
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/uTcZk/src/guides/legendelements.jl:23
  [4] (::AlgebraOfGraphics.var"#213#220"{Vector{Vector{Symbol}}, Vector{Union{Type{Any}, Type{<:AbstractPlot}}}, Dict{Union{Int64, Symbol}, Any}, Vector{Symbol}})(idx::Int64)
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/uTcZk/src/guides/legend.jl:76
  [5] iterate
    @ ./generator.jl:47 [inlined]
  [6] _collect(c::Base.OneTo{Int64}, itr::Base.Generator{Base.OneTo{Int64}, AlgebraOfGraphics.var"#213#220"{Vector{Vector{Symbol}}, Vector{Union{Type{Any}, Type{<:AbstractPlot}}}, Dict{Union{Int64, Symbol}, Any}, Vector{Symbol}}}, #unused#::Base.EltypeUnknown, isz::Base.HasShape{1})
    @ Base ./array.jl:744
  [7] collect_similar(cont::Base.OneTo{Int64}, itr::Base.Generator{Base.OneTo{Int64}, AlgebraOfGraphics.var"#213#220"{Vector{Vector{Symbol}}, Vector{Union{Type{Any}, Type{<:AbstractPlot}}}, Dict{Union{Int64, Symbol}, Any}, Vector{Symbol}}})
    @ Base ./array.jl:653
  [8] map(f::Function, A::Base.OneTo{Int64})
    @ Base ./abstractarray.jl:2849
  [9] compute_legend(grid::Matrix{AxisEntries})
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/uTcZk/src/guides/legend.jl:70
 [10] compute_legend
    @ ~/.julia/packages/AlgebraOfGraphics/uTcZk/src/guides/legend.jl:45 [inlined]
 [11] #legend!#207
    @ ~/.julia/packages/AlgebraOfGraphics/uTcZk/src/guides/legend.jl:15 [inlined]
 [12] #legend!#206
    @ ~/.julia/packages/AlgebraOfGraphics/uTcZk/src/guides/legend.jl:5 [inlined]
 [13] legend!
    @ ~/.julia/packages/AlgebraOfGraphics/uTcZk/src/guides/legend.jl:4 [inlined]
 [14] draw(s::AlgebraOfGraphics.Layers; axis::NamedTuple{(), Tuple{}}, figure::NamedTuple{(:resolution,), Tuple{Tuple{Int64, Int64}}}, palettes::NamedTuple{(), Tuple{}}, facet::NamedTuple{(), Tuple{}}, legend::NamedTuple{(), Tuple{}}, colorbar::NamedTuple{(), Tuple{}})
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/uTcZk/src/algebra/layers.jl:177
 [15] top-level scope
    @ REPL[119]:12
 [16] top-level scope
    @ ~/.julia/packages/Infiltrator/F1Sda/src/Infiltrator.jl:500

See comment below for a data set to reproduce the error.

haberdashPI avatar Jan 23 '22 13:01 haberdashPI

Here is a data set that will reproduce the error:

percent,measure,dataset,decade,mean,mean_lower,mean_upper
0.0009765625,model,a,4,0.2937774622145025,0.28231505609365176,0.30523986833535327
0.0009765625,ground_truth,a,4,0.879216728828697,0.8476973289874712,0.9107361286699227
0.0009765625,model,a,5,0.3156191695075918,0.30303929381936684,0.3281990451958167
0.0009765625,ground_truth,a,5,0.8718709703411108,0.8393077961618249,0.9044341445203967
0.0009765625,model,a,6,0.323709586289669,0.3059136195333758,0.3415055530459622
0.0009765625,ground_truth,a,6,0.8894667211235145,0.84742582502029,0.9315076172267391
0.0009765625,model,a,7,0.3223386095808623,0.29034980852029246,0.35432741064143214
0.0009765625,ground_truth,a,7,0.9245283018867925,0.8510225317390837,0.9980340720345012
0.0009765625,model,b,6,0.43561245151767847,0.41677228971383384,0.4544526133215231
0.0009765625,ground_truth,b,6,0.6340809652185442,0.5888984492871617,0.6792634811499266
0.0009765625,model,b,4,0.4420681661781934,0.4193977430380501,0.46473858931833667
0.0009765625,ground_truth,b,4,0.7033227848101266,0.6517456529542088,0.7548999166660443
0.0009765625,model,b,7,0.40927932677535855,0.3854852857466776,0.4330733678040395
0.0009765625,ground_truth,b,7,0.5855513307984791,0.5256238388356771,0.6454788227612811
0.0009765625,model,b,5,0.4293531675308421,0.41411329653312196,0.4445930385285622
0.0009765625,ground_truth,b,5,0.6350093109869647,0.5941605954650591,0.6758580265088703
0.0009765625,model,c,6,0.6210585535087516,0.6033162895954266,0.6388008174220766
0.0009765625,ground_truth,c,6,1.0,1.0,1.0
0.0009765625,model,c,7,0.601942881496484,0.5767026812409642,0.6271830817520038
0.0009765625,ground_truth,c,7,0.9885496183206107,0.9755821387354563,1.0015170979057653
0.0009765625,model,c,5,0.5722200348197324,0.5513688609023284,0.5930712087371364
0.0009765625,ground_truth,c,5,0.9916666666666667,0.9822312799137959,1.0011020534195376
0.0009765625,model,c,4,0.5556757008244319,0.5305199303419862,0.5808314713068775
0.0009765625,ground_truth,c,4,0.99609375,0.9884011305865239,1.003786369413476
0.001953125,model,a,4,0.3089592070362732,0.2967557700880749,0.32116264398447153
0.001953125,ground_truth,a,4,0.8394513797872398,0.8067743430279484,0.8721284165465313
0.001953125,model,a,5,0.3211764214182011,0.30790635746499256,0.3344464853714096
0.001953125,ground_truth,a,5,0.8191987675686018,0.7848270454042009,0.8535704897330026
0.001953125,model,a,6,0.3321485469019252,0.3134243359297288,0.3508727578741216
0.001953125,ground_truth,a,6,0.8590186908115608,0.816591424917183,0.9014459567059386
0.001953125,model,a,7,0.3173676384443848,0.2810672462204888,0.35366803066828084
0.001953125,ground_truth,a,7,0.8984203892252244,0.8309129466853974,0.9659278317650514
0.001953125,model,b,6,0.4273124818930726,0.4082133535987509,0.4464116101873943
0.001953125,ground_truth,b,6,0.634845629294397,0.5900475751008978,0.6796436834878963
0.001953125,model,b,4,0.4536933663215438,0.42967619714036237,0.4777105355027252
0.001953125,ground_truth,b,4,0.6941515297936537,0.6420714027662343,0.7462316568210731
0.001953125,model,b,7,0.4066758181678698,0.3810178114741354,0.4323338248616042
0.001953125,ground_truth,b,7,0.5795897151481747,0.5198895246355694,0.63928990566078
0.001953125,model,b,5,0.4336635723633834,0.4168562083825619,0.4504709363442049
0.001953125,ground_truth,b,5,0.6260397403421664,0.5851566393729323,0.6669228413114004
0.001953125,model,c,6,0.635909874885791,0.6181629614558233,0.6536567883157587
0.001953125,ground_truth,c,6,0.9983091787439612,0.9949879345838075,1.0016304229041149
0.001953125,model,c,7,0.6092376731478518,0.5835402943308279,0.6349350519648758
0.001953125,ground_truth,c,7,0.9921119592875318,0.9814945279007986,1.002729390674265
0.001953125,model,c,5,0.5775404218433574,0.5544610140556537,0.6006198296310611
0.001953125,ground_truth,c,5,0.9916666666666667,0.9824307293621447,1.0009026039711886
0.001953125,model,c,4,0.5815936971827135,0.5558416790367825,0.6073457153286445
0.001953125,ground_truth,c,4,0.99609375,0.9884011305865239,1.003786369413476
0.0029296875,model,a,4,0.30742006782646014,0.29479471963532783,0.32004541601759245
0.0029296875,ground_truth,a,4,0.7548909458506765,0.7165400666945239,0.7932418250068292
0.0029296875,model,a,5,0.32030299442960314,0.30608962896111247,0.3345163598980938
0.0029296875,ground_truth,a,5,0.7089749401915678,0.6682850265907051,0.7496648537924305
0.0029296875,model,a,6,0.3286770933705504,0.309748267855385,0.3476059188857158
0.0029296875,ground_truth,a,6,0.7772110869612302,0.7257684464082573,0.8286537275142031
0.0029296875,model,a,7,0.31552633913994793,0.27630323307549143,0.35474944520440443
0.0029296875,ground_truth,a,7,0.7685451720087124,0.661541851055177,0.8755484929622478
0.0029296875,model,b,6,0.4265239741795705,0.4067572260526293,0.4462907223065117
0.0029296875,ground_truth,b,6,0.6322359259475622,0.587230621745831,0.6772412301492934
0.0029296875,model,b,4,0.4443769906123892,0.4199275743021381,0.4688264069226403
0.0029296875,ground_truth,b,4,0.6897864324800121,0.637674017435387,0.7418988475246373
0.0029296875,model,b,7,0.40793179303744953,0.3814246286816127,0.43443895739328636
0.0029296875,ground_truth,b,7,0.5904250146506552,0.5310856070255333,0.6497644222757771
0.0029296875,model,b,5,0.4291606130422872,0.411703413271406,0.44661781281316837
0.0029296875,ground_truth,b,5,0.6156508103613701,0.5744510088825068,0.6568506118402335
0.0029296875,model,c,6,0.6387361494912613,0.6205515698248888,0.6569207291576339
0.0029296875,ground_truth,c,6,0.9981884057971014,0.9946299299112225,1.0017468816829804
0.0029296875,model,c,7,0.6123717429967978,0.5840276096169332,0.6407158763766623
0.0029296875,ground_truth,c,7,0.9956743002544529,0.9880959669292099,1.0032526335796959
0.0029296875,model,c,5,0.5851608105087508,0.5610896729959347,0.6092319480215669
0.0029296875,ground_truth,c,5,0.9916666666666667,0.9822312799137959,1.0011020534195376
0.0029296875,model,c,4,0.5651966809921953,0.5380641522744505,0.5923292097099402
0.0029296875,ground_truth,c,4,0.99609375,0.9884011305865239,1.003786369413476

haberdashPI avatar Jan 23 '22 13:01 haberdashPI