我正在将“计数”样式的数据框传递给 Gadfly 以制作条形图。当我使用垂直方向时输出与预期的一样,但当我使用水平方向时它会中断。我是不是误解了什么,还是应该提交一份快速的问题报告?谢谢!
using Gadfly
using DataFrames
import Cairo, Fontconfig
df = DataFrame(group = ["A", "B", "C", "D"], count = [5,10,25,15])
vertPlot = plot(df, x = :group, y = :count, Geom.bar(orientation = :vertical))
horiPlot = plot(df, x = :group, y = :count, Geom.bar(orientation = :horizontal))
plot(df, x = :group, y = :count, Geom.bar(orientation = :vertical)) |> SVG("vertical.svg") # fine
plot(df, x = :group, y = :count, Geom.bar(orientation = :horizontal)) |> SVG("horizontal.svg") # RIP
堆栈跟踪:
[thadryan@leon Test]
~:) julia ErrorInPlotWhenHorizonatal.jl
ERROR: LoadError: MethodError: no method matching zero(::Type{String})
Closest candidates are:
zero(::Type{Missing}) at missing.jl:103
zero(::Type{Pkg.Resolve.FieldValue}) at /build/julia/src/julia-1.5.4/usr/share/julia/stdlib/v1.5/Pkg/src/Resolve/fieldvalues.jl:38
zero(::Type{Pkg.Resolve.VersionWeight}) at /build/julia/src/julia-1.5.4/usr/share/julia/stdlib/v1.5/Pkg/src/Resolve/versionweights.jl:15
...
Stacktrace:
[1] apply_statistic(::Gadfly.Stat.BarStatistic, ::Dict{Symbol,Gadfly.ScaleElement}, ::Gadfly.Coord.Cartesian, ::Gadfly.Aesthetics) at /home/thadryan/.julia/packages/Gadfly/nN3lf/src/statistics.jl:239
[2] apply_statistics(::Array{Gadfly.StatisticElement,1}, ::Dict{Symbol,Gadfly.ScaleElement}, ::Gadfly.Coord.Cartesian, ::Gadfly.Aesthetics) at /home/thadryan/.julia/packages/Gadfly/nN3lf/src/statistics.jl:33
[3] render_prepare(::Plot) at /home/thadryan/.julia/packages/Gadfly/nN3lf/src/Gadfly.jl:680
[4] render(::Plot) at /home/thadryan/.julia/packages/Gadfly/nN3lf/src/Gadfly.jl:740
[5] draw at /home/thadryan/.julia/packages/Gadfly/nN3lf/src/Gadfly.jl:847 [inlined]
[6] SVG at /home/thadryan/.julia/packages/Compose/5GmGj/src/svg.jl:286 [inlined]
[7] |>(::Plot, ::SVG) at ./operators.jl:834
[8] top-level scope at /home/thadryan/Workspace/Test/ErrorInPlotWhenHorizonatal.jl:12
in expression starting at /home/thadryan/Workspace/Test/ErrorInPlotWhenHorizonatal.jl:12
我的直觉是它期望计算一些东西,没有给它一个数字,但我不确定我是否不熟悉牛虻的内部运作。版本信息:
朱莉娅:1.5.4 (2021-03-11)
julia> Pkg.status("Gadfly")
Status `~/.julia/environments/v1.5/Project.toml`
[c91e804a] Gadfly v1.3.2
julia> Pkg.status("DataFrames")
Status `~/.julia/environments/v1.5/Project.toml`
[a93c6f00] DataFrames v0.22.5
julia> Pkg.status("Cairo")
Status `~/.julia/environments/v1.5/Project.toml`
[159f3aea] Cairo v1.0.5
julia> Pkg.status("Fontconfig")
Status `~/.julia/environments/v1.5/Project.toml`
[186bb1d3] Fontconfig v0.4.0