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

Possible bug: Geom.bar fails when given horizontal orientation argument but works fine with vertical #1527

Closed
thadryanjs opened this issue Mar 22, 2021 · 2 comments

Comments

@thadryanjs
Copy link

I've documented the issue on this SO post for posterity but paste here also.

Thanks in advance and thanks for working on this! It's a very cool idea.

post:

I am passing a "dict-of-counts" style dataframe to Gadfly to make a barplot. The output is as expected when I use the vertical orientation, but it breaks when I use horizontal. Am I misunderstanding something or should I file a quick issue report? Thanks!

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

The stack trace:

[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

My instinct is that it's expecting to count something, not have a number given to it but I'm not sure I'm not familiar with the inner workings of Gadfly.
Version info:

Julia: 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
@Mattriks
Copy link
Member

See #1266 (comment)

@thadryanjs
Copy link
Author

Thanks, I've got what I'm looking for! I assume it would be like coord_flip() - I'll change the title of the SO post so it will be more discover-able for the next confused R user. Might be worth considering a specific error message for this at some point.

Thanks again!

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

No branches or pull requests

2 participants