Seaborn like countplot

I was looking for a recipe for the type of plot used in Seaborn to group categorical data. The Countplot, shown below from python is what I want.


Is this implemented in julia or easy to do so?

With VegaLite.jl, something like this?

using DataFrames, VegaLite

df = DataFrame(is_bad=rand(Bool, 10_000))

df |> @vlplot(:bar, x="is_bad:n", y="count()")
3 Likes

This is not se easy to do in Plots, though the recipe would be easy to add.

using StatsBase, Plots
d = countmap(rand(0:1, 10_000))
bar(collect(keys(d)), collect(values(d)))

We should add a recipe for Dict that obviated the bottom call.

The best I could do using juliadb table t (i added a column called β€˜ones’):
a = groupby(sum, pushcol(t, :ones, ones(1:n_examples)), :is_bad, select=:ones)

Table with 2 rows, 2 columns:
is_bad sum
──────────────
0 8705.0
1 1295.0

@df a bar!(:sum)

Any suggestions?