-
Notifications
You must be signed in to change notification settings - Fork 250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
force type Vector{Colorant}
for ManualDiscreteKey
#1470
Conversation
Vector{Colorant}
in for ManualDiscreteKey
Vector{Colorant}
for ManualDiscreteKey
Codecov Report
@@ Coverage Diff @@
## master #1470 +/- ##
=======================================
Coverage 89.32% 89.32%
=======================================
Files 39 39
Lines 4395 4395
=======================================
Hits 3926 3926
Misses 469 469
Continue to review full report at Codecov.
|
Is this due to a type piracy issue by another package like in #1466? i.e. Can you demonstrate that the above error is caused by using Gadfly alone, without some other package being the root cause? |
Hi ah, this is likely the same problem then:
This PR should be pretty harmless, since it only changes colors object type a little earlier in the stack, rather than an automated |
Can you give an example of your plot which uses |
yes, on Gadfly#master---and doesn't error without Images---but this does using Gadfly, Images
Guide.manual_color_key("Legend", ["red"; "blue"], parse.(Colorant, ["red";"blue"]))
ERROR: TypeError: in new, expected Array{Colorant,1}, got a value of type Array{RGB{Normed{UInt8,8}},1}
Stacktrace:
[1] ManualDiscreteKey at /home/dehann/.julia/packages/Gadfly/asb1x/src/guide/keys.jl:267 [inlined]
[2] Gadfly.Guide.ManualDiscreteKey(; title::String, labels::Array{String,1}, pos::Array{Any,1}, color::Array{RGB{Normed{UInt8,8}},1}, shape::Array{Function,1}, size::Array{Measures.Measure,1}) at /home/dehann/.julia/packages/Gadfly/asb1x/src/guide/keys.jl:295
[3] #manual_color_key#131 at /home/dehann/.julia/packages/Gadfly/asb1x/src/guide/keys.jl:321 [inlined]
[4] manual_color_key(::String, ::Array{String,1}, ::Array{RGB{Normed{UInt8,8}},1}) at /home/dehann/.julia/packages/Gadfly/asb1x/src/guide/keys.jl:321
[5] top-level scope at REPL[16]:1 EDIT, to better answer your question, the code works as follows: function draw1D!(....; legend=nothing,....)
# ...
ptArr = []
for bla in blabla
push!(ptArr, Gadfly.layer(...))
end
if legend != nothing
push!(ptArr, legend)
end
# ...
return Gadfly.plot(ptArr...)
end
vecStrings = ["red";"blue"]
lg = Guide.manual_color_key("Legend", legend, parse.(Colorant, vecStrings))
H=draw1D!(....,legend=lg,....) REF: |
An alternative suggestion here might be to force the express field type ManualDiscreteKey(title, labels, pos, clrs::Vector{<:Colorant}, shps, szs, vis) = new(title, labels, pos, Vector{Colorant}(clrs), shps, szs, vis) This might be more fitting than only 'fixing' the type inside the convenience constructor This would likely not have any performance impact, since the struct type is already |
Thanks for the extra info about your style of plot. It is possible to automate the colorkey, and we are working to further increase support for this new style syntax. Here are some examples:
Feedback welcome! |
Thanks, will work through the examples you listed, and more automation on colorkey is great news! Thanks again. Regarding the type piracy problem from ImageCore.jl, perhaps we should leave this PR open so others can find it more easily, but then close this PR when JuliaImages/ImageCore.jl#131 is merged and tagged? |
Hi, I just tried this again and looks to be resolved (following recent ImageCore.jl tag). I tried with latest Consequently @Mattriks , perhaps I could ask for a new tag on Gadfly.jl if possible please? We are having Pkg compat issues downstream which likely follow from this type piracy problem -- we think that a new release tag on Gadfly will help resolve the problem. cc @Affie EDIT: I should add that the compat issue seems to be a combination recent Optim v1.0.0 and ImageCore tags. It's a bit hard to debug, but installing |
Fixes an unexpected dispatch problem with a minimal code change. Seemed like the best solution after various attempts to fix downstream with user code, but didn't work. This issue also seems to be a regression since the user code has been working for quite some time.
Not sure if this is related, but:
Contributor checklist:
NEWS.md
squash
'ed orfixup
'ed junk commits with git-rebaseProposed changes
Vector{Colorant}
forManualDiscreteKey
in guide/keys.jl