Line

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

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

  • hue (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

  • hue_manager (object) – a ContinuousHueManager or DiscreteHueManager instance to control line hue

  • 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

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

Note

x-axis values can be int,float,datetime.datetime or datetime.timedelta y-axis values can be int,float,datetime.datetime or datetime.timedelta

None values are permitted in some data values with the following effect:

y: point not plotted, line will be broken size: point assigned default size hue: points assigned default hue

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.common import DiscreteHueLegend

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()

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

d.add(l)

legend = DiscreteHueLegend(l.getHueManager(),400,legend_columns=2, stroke_width=5)
legend.setDiscreteMarkerStyle("line")
d.add(legend)

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

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