class, x=0, y=1, hue=None, stacked=True, width=512, height=512, hue_manager=None, stroke='black', stroke_width=2, font_height=12, spacing_fraction=0.1, text_attributes={}, value_formatter=None, display_totals=False)

Create a Bar Chart


data (dict) – A relational data set (for example, list of dicts/lists/tuples describing each row)

Keyword Arguments
  • x (str or int) – Identify the column to yield discrete values

  • y (str or int) – Identify the column to measure on the y-axis (use count if not specified)

  • hue (str or int) – Identify the column to define the bar hue (use hue_manager default hue if not specified)

  • stacked (bool) – When hue is defined, choose wether to stack hueed bars or display them side by side

  • width (int) – the width of the plot in pixels

  • height (int) – the height of the plot in pixels

  • hue_manager (list) – a DiscreteHueManager|ContinuousHueManager object

  • stroke (str) – stroke color for bars

  • stroke_width (int) – stroke width for bars

  • font_height (int) – the height of the font for text labels

  • spacing_fraction (float) – ratio of bar width to spacing

  • text_attributes (dict) – SVG attribute name value pairs to apply to labels

  • value_formatter (visigoth.utils.ValueFormatter) – control the way values are represented

  • display_totals (bool) – whether to display a total above each bar


y-axis columns must be float or integer


(Link to open example in new tab):

Source Code (Link to Github):

# -*- coding: utf-8 -*-

from visigoth.diagram import Diagram
from import Bar
from visigoth.containers import Box
from visigoth.common.legend import DiscreteHueLegend
from visigoth.utils import DiscreteHueManager

data = [{"c1":"A","c2":10,"c3":"AAA"},{"c1":"B","c2":-5,"c3":"BBB"},{"c1":"C","c2":6,"c3":"AAA"},{"c1":"D","c2":8,"c3":"DDD"}]

d = Diagram()

bar1 = Bar(data,x="c1",y="c2",hue="c3",width=400, height=400,hue_manager=DiscreteHueManager())
legend = DiscreteHueLegend(bar1.getHueManager(),400)

html = d.draw(format="html")
f = open("example.html", "w")