{
"title": "bar",
"category": "plotting",
"keywords": [
"bar",
"bar chart",
"grouped bar chart",
"stacked bar chart",
"matlab bar",
"categorical comparison"
],
"summary": "Create bar charts for categorical comparisons, grouped series, stacked values, and MATLAB `bar` workflows.",
"gpu_support": {
"elementwise": false,
"reduction": false,
"precisions": [
"single",
"double"
],
"broadcasting": "none",
"notes": "`bar` uses the modern bar/surface-style rendering path, including GPU-backed paths for supported input combinations."
},
"fusion": {
"elementwise": false,
"reduction": false,
"max_inputs": 1,
"constants": "inline"
},
"requires_feature": null,
"tested": {
"unit": "builtins::plotting::bar::tests",
"integration": "runmat-plot/tests/renderer_tests.rs"
},
"description": "`bar` creates vertical bar charts from vectors or matrix-style inputs. In RunMat it returns a bar handle, supports the common MATLAB `bar(y)` workflows as well as grouped and stacked behaviors, and integrates with the shared handle/property system.",
"behaviors": [
"Vector inputs create a single bar series with implicit category positions.",
"Matrix inputs support grouped and stacked bar-style rendering workflows.",
"The returned value is a bar handle that can be queried and updated through `get` and `set`.",
"Display names, bar width, and face color participate in the shared plotting object/property model.",
"RunMat prefers GPU-backed rendering when supported input/layout combinations are present, while preserving the same bar semantics on fallback paths."
],
"examples": [
{
"description": "Create a basic bar chart from a vector",
"input": "values = [3 5 2 9];\nbar(values);"
},
{
"description": "Create grouped bars from a matrix",
"input": "Y = [3 5 2; 4 6 1; 5 4 3];\nbar(Y);"
},
{
"description": "Style a bar object and label it for the legend",
"input": "h = bar([2 4 1 5]);\nset(h, 'FaceColor', 'g', 'DisplayName', 'counts');\nlegend;"
}
],
"links": [
{ "label": "hist", "url": "./hist" },
{ "label": "histogram", "url": "./histogram" },
{ "label": "pie", "url": "./pie" },
{ "label": "legend", "url": "./legend" },
{ "label": "set", "url": "./set" }
],
"source": {
"label": "`crates/runmat-runtime/src/builtins/plotting/ops/bar.rs`",
"url": "https://github.com/runmat-org/runmat/blob/main/crates/runmat-runtime/src/builtins/plotting/ops/bar.rs"
},
"gpu_residency": "`bar` preserves GPU residency where the bar geometry pipeline can consume exported buffers directly. Fallback rendering gathers once and preserves the same grouping/stacking semantics.",
"gpu_behavior": [
"Bar rendering shares the same plotting architecture as the rest of the plotting stack."
]
}