Line

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

Create an Line plot

Parameters:

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

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
  • colour (str or int) – Identify the column to specify the line to which each point belongs
  • 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) – specify the width of the lines in pixels
  • 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 -*-

import random
import datetime

from visigoth import Diagram
from visigoth.charts import Line
from visigoth.containers import Box
from visigoth.common import Legend

r = random.Random()
data = []
y = -0.05
for cat in ["A","B","C","D"]:
    for idx in range(36):
        data.append((datetime.datetime(2018,1,1,0,idx,0),y+r.random()/10,cat))
    y += 0.1

d = Diagram()

al = Line(data,x=0,y=1,colour=2,width=600,height=600)
(ax,ay) = al.getAxes()
ax.setLabel("X axis")
ay.setLabel("Y axis")

d.add(Box(al))

legend = Legend(al.getPalette(),400,legend_columns=2, stroke_width=5)
legend.setDiscreteMarkerStyle("line")
d.add(legend)
d.connect(legend,"colour",al,"colour")
d.connect(al,"colour",legend,"colour")

html = d.draw(format="html",html_title="Visigoth - Line Chart Example")

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