Skip to content
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

Exception in apply_scales() when using multiple layers+DataFrame+color keys #1171

Open
azurefx opened this issue Jun 26, 2018 · 2 comments · May be fixed by #1436
Open

Exception in apply_scales() when using multiple layers+DataFrame+color keys #1171

azurefx opened this issue Jun 26, 2018 · 2 comments · May be fixed by #1436

Comments

@azurefx
Copy link

azurefx commented Jun 26, 2018

using Gadfly
using DataFrames
f(x,y)=x^2+y^2
xs=-1:0.01:1
ys=-1:0.01:1
mat=[
    0 0 "A";
    0.5 0.5 "A";
    0 0 "B";
    0.5 -0.5 "B";
    0 0 "C";
    -0.5 0.5 "C"
]
df=DataFrame(x=Float64[],y=Float64[],series=String[])
for i in indices(mat,1)
    push!(df,mat[i,:])
end
categorical!(df,:series)

#OK
plot(
    layer(x=xs,y=ys,z=f,Geom.contour)
)
#OK
plot(
    layer(df,x=:x,y=:y,color=:series)
)
#OK
plot(
    layer(x=xs,y=ys,z=f,Geom.contour),
    layer(df,x=:x,y=:y)
)
#FAILED
plot(
    layer(x=xs,y=ys,z=f,Geom.contour),
    layer(df,x=:x,y=:y,color=:series)
)

Error showing value of type Gadfly.Plot: ERROR: MethodError: Cannotconvertan object of type String to an object of type Float64 This may have arisen from a call to the constructor Float64(...), since type constructors fall back to convert methods. Stacktrace: [1] convert(::Type{Float64}, ::CategoricalArrays.CategoricalString{UInt32}) at C:\Users\Azure\.julia\v0.6\CategoricalArrays\src\value.jl:67 [2] apply_scale(::Gadfly.Scale.ContinuousColorScale, ::Array{Gadfly.Aesthetics,1}, ::Gadfly.Data, ::Vararg{Gadfly.Data,N} where N) at C:\Users\Azure\.julia\v0.6\Gadfly\src\scale.jl:546 [3] apply_scales(::IterTools.Distinct{Base.ValueIterator{Dict{Symbol,Gadfly.ScaleElement}},Gadfly.ScaleElement}, ::Array{Gadfly.Aesthetics,1}, ::Gadfly.Data, ::Vararg{Gadfly.Data,N} where N) at C:\Users\Azure\.julia\v0.6\Gadfly\src\scale.jl:34 [4] apply_scales(::IterTools.Distinct{Base.ValueIterator{Dict{Symbol,Gadfly.ScaleElement}},Gadfly.ScaleElement}, ::Gadfly.Data, ::Gadfly.Data, ::Vararg{Gadfly.Data,N} where N) at C:\Users\Azure\.julia\v0.6\Gadfly\src\scale.jl:53 [5] render_prepare(::Gadfly.Plot) at C:\Users\Azure\.julia\v0.6\Gadfly\src\Gadfly.jl:677 [6] render(::Gadfly.Plot) at C:\Users\Azure\.julia\v0.6\Gadfly\src\Gadfly.jl:755 [7] show at C:\Users\Azure\.julia\v0.6\Gadfly\src\Gadfly.jl:959 [inlined] [8] verbose_show(::Base.AbstractIOBuffer{Array{UInt8,1}}, ::MIME{Symbol("image/svg+xml")}, ::Gadfly.Plot) at .\multimedia.jl:42 [9] #sprint#228(::Void, ::Function, ::Int64, ::Function, ::MIME{Symbol("image/svg+xml")}, ::Vararg{Any,N} where N) at .\strings\io.jl:66 [10] reprmime(::MIME{Symbol("image/svg+xml")}, ::Gadfly.Plot) at .\multimedia.jl:61 [11] stringmime at .\multimedia.jl:83 [inlined] [12] display(::_vscodeserver.InlineDisplay, ::MIME{Symbol("image/svg+xml")}, ::Gadfly.Plot) at C:\Users\Azure\.vscode\extensions\julialang.language-julia-0.10.2\scripts\terminalserver\terminalserver.jl:167 [13] display(::_vscodeserver.InlineDisplay, ::Gadfly.Plot) at C:\Users\Azure\.vscode\extensions\julialang.language-julia-0.10.2\scripts\terminalserver\terminalserver.jl:198 [14] display(::Gadfly.Plot) at .\multimedia.jl:218 [15] hookless(::Media.##7#8{Gadfly.Plot}) at C:\Users\Azure\.julia\v0.6\Media\src\compat.jl:14 [16] render(::Media.NoDisplay, ::Gadfly.Plot) at C:\Users\Azure\.julia\v0.6\Media\src\compat.jl:27 [17] display(::Media.DisplayHook, ::Gadfly.Plot) at C:\Users\Azure\.julia\v0.6\Media\src\compat.jl:9 [18] display(::Gadfly.Plot) at .\multimedia.jl:218 [19] eval(::Module, ::Any) at .\boot.jl:235 [20] print_response(::Base.Terminals.TTYTerminal, ::Any, ::Void, ::Bool, ::Bool, ::Void) at .\REPL.jl:144 [21] print_response(::Base.REPL.LineEditREPL, ::Any, ::Void, ::Bool, ::Bool) at .\REPL.jl:129 [22] (::Base.REPL.#do_respond#16{Bool,_vscodeserver.##3#4,Base.REPL.LineEditREPL,Base.LineEdit.Prompt})(::Base.LineEdit.MIState, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Bool) at .\REPL.jl:646

@azurefx azurefx changed the title Exception in apply_scale when using multiple layers+DataFrame+color keys Exception in apply_scales() when using multiple layers+DataFrame+color keys Jun 26, 2018
@Mattriks
Copy link
Member

See #1098 and my #1098 (comment)

@azurefx
Copy link
Author

azurefx commented Jun 26, 2018

Thanks for your workaround! I hope this can be supported in the future.

@Mattriks Mattriks mentioned this issue Jan 19, 2020
@Mattriks Mattriks linked a pull request May 8, 2020 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants