Skip to content

Bar

Compare categories with regular, stacked, grouped, or aggregate bars.

AI-assisted, human-approvednovem uses AI to review and keep our documentation up to date.

Overview

Bar charts support four arrangements:

  • bar: one bar per value.
  • sbar: values stacked within each category.
  • gbar: values grouped beside each other within each category.
  • abar: the sum of the value columns for each category.

Prefix a type with h for horizontal bars, i for an inverted axis, or ih for both. For example, ibar draws bars from the top and ihbar draws them from the right.

/vis/plots/<name>/config/type

Regular  Horizontal  Inverted  Inverted Horizontal
-------  ----------  --------  -------------------
bar      hbar        ibar      ihbar
sbar     hsbar       isbar     ihsbar
gbar     hgbar       igbar     ihgbar
abar     habar       iabar     ihabar

Structure

Bar charts use the standard plot structure:

en_letter_frequency      => Name
├── config               => Configuration options
│   ├── caption          => Caption below chart
│   ├── title            => Title of chart
│   └── type             => bar, sbar, gbar etc...
├── data                 => data to chart
├── description          => Description (meta)
├── name                 => Name (meta)
└── shared               => Sharing information
    ├── +org~group       => Shared with an org group
    ├── @username~group  => Shared with a user group
    └── public           => Shared with everyone

Data

curl -X POST https://api.novem.io/v1/vis/plots/example_counts/data \
  -H "Authorization: Bearer <your_token>" \
  -H "Content-Type: text/plain" \
  --data-binary "@data.csv"

Write the chart values to data. The first column supplies category labels; subsequent columns supply numeric series. The category axis is horizontal for vertical bars and vertical for horizontal bars.

Bar chart types

The embedded examples below use public novem_demo plots.

Regular

Stacked

Grouped

Aggregate

Aggregate plots are identical to regular plots, except they represent the sum of the columns for each category label.

Outputs

Available formats are listed under files/:

  • pdf and png: rendered chart.
  • txt and ansi: terminal output, with colour in the ANSI version.
  • csv and xlsx: chart data.

See File formats for details.

Examples

Create a bar chart

Save these fictional counts as counts.csv:

Group,Count
A,10
B,20
C,15

Choose the CLI, Python, or HTTP example below to create the plot, upload the data, and read its URL. The HTTP example uses an API token from the NOVEM_TOKEN environment variable.

novem -p example_counts -C
novem -p example_counts -w data @counts.csv
novem -p example_counts -w config/type bar
novem -p example_counts -w config/title "Example counts"
novem -p example_counts -w config/caption "Fictional data for this example."
novem -p example_counts -r url

Open the returned URL while signed in. It should show three bars with values 10, 20, and 15. To make the bars horizontal, change the type:

novem -p example_counts -w config/type hbar