Qu

sns_bar

Builtin index · Plotting

sns_bar(df, groupcol, valuecol, [agg])

Input: df, groupcol, valuecol, agg · Output: no output

What it is

Aggregates column valuecol (string, column name) within each distinct value of groupcol (string, column name) of Table df, using aggregator agg (string, positional, default "mean"; also accepts things like "sum"/"median" depending on what the underlying aggregation supports), and plots the one resulting number per group as bars.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
sns_bar(df, groupcol, valuecol, [agg])
df string or Tablenot documented yet
groupcol string or Tablenot documented yet
valuecol string or Tablenot documented yet
agg string or Table, optionalnot documented yet
no output—

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

df = table(x = randn(30, seed = 1), y = randn(30, seed = 2),
           grp = ["a","b","a","b","a","b","a","b","a","b",
                  "a","b","a","b","a","b","a","b","a","b",
                  "a","b","a","b","a","b","a","b","a","b"])
sns_scatter(df, "x", "y", "grp")
figure()
sns_box(df, "grp", "y")
figure()
sns_bar(df, "grp", "y")
print("rows: " + str(rows(df)))
output
rows: 30
0 0.02 0.04 0.06 0.08 0.10 0.12 0.14 0.16 0.18 0.20 0.22 0.24 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1.0 1.2 1.4 1.6 x=0, y=0.138 x=1, y=0.241

from plotting

How it works

sns_bar(df, groupcol, valuecol, [agg]) — aggregates (mean by default) valuecol within each groupcol value and plots the result as real bars (reuses Table::group_by_agg).

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.