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

hist should work on categorical inputs #4409

Open
asinghvi17 opened this issue Sep 25, 2024 · 0 comments
Open

hist should work on categorical inputs #4409

asinghvi17 opened this issue Sep 25, 2024 · 0 comments
Labels
enhancement Feature requests and enhancements

Comments

@asinghvi17
Copy link
Member

asinghvi17 commented Sep 25, 2024

Feature description

hist fails on categorical inputs, either Strings or values wrapped in Categorical.

grain = rand(["clay", "silt", "sand"], 36)
hist(grain)
hist(Categorical(grain))

Ideally, what I posted above would "just work". The input to hist is arguably all along the x axis, so maybe expanding dimensions could fix it?

It currently fails at:

  [8] pick_hist_edges(vals::CategoricalVector{String, UInt32, String, CategoricalValue{String, UInt32}, Union{}}, bins::Int64)
    @ Makie ~/.julia/dev/Makie/src/stats/hist.jl:151

The current workaround for this is

using StatsBase
pcm = collect(pairs(StatsBase.countmap(grain)))
barplot(Categorical(first.(pcm)), last.(pcm))

download-21

@asinghvi17 asinghvi17 added the enhancement Feature requests and enhancements label Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature requests and enhancements
Projects
None yet
Development

No branches or pull requests

1 participant