Plot Bar
plot_barDraw grouped or stacked bar charts and histograms from CSV or inline JSON, with optional error bars, value labels, and limit lines, and export deterministic SVG, PNG, and plot data JSON.
Instructions
Draw a bar chart (categories x up to 6 series, grouped or stacked, optional error bars and value labels) or a histogram of one column (2..200 bins or explicit edges; counts, density or cumulative) as a deterministic SVG plus plot_data.json with the bin edges and counts (hlines mark limits), and by default plot.png, a 1600 px wide picture (format=both; data.png_path; needs the png extra) that also comes back as an image in the reply (inline_image): hand over the PNG, not the SVG path. Data: a CSV with a header row or inline JSON series.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "plot_bar"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bins | No | Histogram: number of equal bins over the data range, 2..200; 0 = Sturges rule ceil(log2 n)+1. | |
| grid | No | true draws horizontal grid lines at the y ticks; false draws none. | |
| mode | No | bar (categories and values) or histogram (distribution of one column of numbers). | bar |
| theme | No | auto (follows the viewer's light/dark), light, dark, or print (black and grey). | auto |
| title | No | Chart title, plain text <= 120 characters, e.g. 'Cycle ranges'; blank = none. | |
| width | No | SVG width in px, 200..2400, e.g. 800. | |
| format | No | Picture file: both (default: plot.svg + plot.png 1600 px wide; PNG needs the png extra), svg (no PNG) or png (no SVG). | both |
| height | No | SVG height in px, 200..2400, e.g. 450. | |
| hlines | No | Horizontal limit lines 'value,label;...' in y units, e.g. '250,yield;-250,'; at most 10; the y axis grows to show them. | |
| legend | No | auto (2+ series), off, top_right, top_left, bottom_right, bottom_left or right (outside the plot). | auto |
| series | No | Inline JSON [{"name":"2025","x":["A","B"],"y":[3,5],"err":[0.2,0.4]}]; bar: <=6 series, same x; histogram: one, y used. | |
| x_label | No | x axis title with unit, plain text <= 120 characters, e.g. 'Stress range (MPa)'. | |
| y_label | No | y axis title with unit, plain text <= 120 characters, e.g. 'Cycles'. | |
| y_range | No | Fixed y axis 'min,max': plain numbers in the axis unit, no unit text, e.g. '0,50' (not '0,50 kN'); blank = automatic from 0. | |
| stacking | No | grouped (bars side by side) or stacked (positives up, negatives down); bar mode with 2+ series. | grouped |
| x_column | No | Bar mode, CSV: the category column (text allowed), e.g. 'part'; blank = the first column. | |
| bin_edges | No | Histogram: explicit increasing edges 'e0,e1,...', e.g. '0,50,100,200' (3..201 values); instead of bins. | |
| data_file | No | CSV/TXT path with a header row, e.g. ws/<job>/rainflow_cycles.csv. Give this or 'series'. | |
| histogram | No | Histogram heights: counts, density (bars integrate to 1) or cumulative counts. | counts |
| y_columns | No | CSV value columns, e.g. 'q1,q2' (bar, <=6) or one column (histogram); blank = numeric columns / first column. | |
| err_columns | No | Bar mode, CSV: error-bar half widths, one column per y column in the same order, e.g. 'q1_err,q2_err'. | |
| inline_image | No | true (default): the PNG also comes back as an image block in the reply when it is <= 600 kB; false: path only. | |
| value_labels | No | true writes each bar's value above it (stacked: the total); skipped where a bar is too narrow. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ok | Yes | ||
| data | No | Non-quantity payload (reports, listings) | |
| error | No | ||
| value | No | Primary quantity result | |
| values | No | All named quantity results (includes the primary) | |
| warnings | No | ||
| artifacts | No | ||
| provenance | Yes | What produced the result and from which inputs. | |
| review_status | No | unreviewed |