Area

class visigoth.charts.area.Area(data, x=0, y=1, colour=2, id=None, label=None, size=None, width=768, height=768, palette=None, marker_manager=None, smoothing=0.0, line_width=4, font_height=24, text_attributes={})

Create a stacked area plot

Parameters:

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

Keyword Arguments:
 
  • x (str or int) – Identify the column to specify x-axis point value
  • y (str or int) – Identify the column to specify y-axis point value. Y values should be positive.
  • colour (str or int) – Identify the column to define the area and colour
  • id (str or int) – Identify the column to define the unique id of each point
  • label (str or int) – Identify the column to define the label of each point
  • size (str or int) – Identify the column to determine the size of each point
  • width (int) – the width of the plot including axes
  • height (int) – the height of the plot including axes
  • palette (object) – a ContinuousPalette or DiscretePalette instance to control line colour
  • marker_manager (object) – a MarkerManager instance to control marker appearance
  • smoothing (float) – smoothing factor to apply to lines, 0.0=no smoothing
  • line_width (int) – width of the lines
  • font_height (int) – the height of the font for text labels
  • text_attributes (dict) – SVG attribute name value pairs to apply to labels

Example

(Link to open example in new tab):

Source Code (Link to Github):

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

from visigoth.diagram import Diagram
from visigoth.charts.area import Area
from visigoth.common.legend import Legend

data = [(0,1,"A"),(1,1.5,"A"),(2,1.6,"A"),(3,1.3,"A"),(4,1.2,"A")] + \
    [(0,4,"B"),(1,3.5,"B"),(2,2.6,"B"),(3,1.6,"B"),(4,0.8,"B")] + \
    [(0,1,"C"),(1,1.7,"C"),(2,2.6,"C"),(3,2.8,"C"),(4,3.1,"C")]

d = Diagram(fill="white")

a = Area(data,width=500,height=400)

d.add(a)
legend = Legend(a.getPalette(),width=400,legend_columns=2)
d.add(legend)

html = d.draw(format="html")

f = open("example.html", "w")
f.write(html)
f.close()