Scatter

class visigoth.charts.scatter.Scatter(data, x=0, y=1, width=768, height=768, colour=None, label=None, size=None, slice=None, palette=None, marker_manager=None, font_height=24, text_attributes={})

Create a Scatter 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 provide the x-axis value for each point

  • y (str or int) – Identify the column to provide the y-axis value for each point

  • width (int) – the width of the plot including axes

  • height (int) – the height of the plot including axes

  • colour (str or int) – Identify the column to define the point colour (use palette default colour if not specified)

  • label (str or int) – Identify the column to define the label

  • size (str or int) – Identify the column to determine the size of each marker

  • slice (str or int) – Identify the column to determine the slice to which each marker belongs

  • palette (object) – a ContinuousPalette or DiscretePalette instance to control chart colour

  • marker_manager (object) – a MarkerManager instance to control marker appearance

  • 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

from visigoth.diagram import Diagram
from visigoth.charts import Scatter
from visigoth.utils.colour import DiscretePalette
from visigoth.common import Legend

palette = DiscretePalette()

r = random.Random()
data = []
for idx in range(0,100):
    data.append((r.random(),r.random(),"p"+str(idx),r.choice(["A","B","C","D"]),r.choice([3,5,9])))

d = Diagram()

scatter = Scatter(data, x=0, y=1, label=2, colour=3, size=4, palette=palette)
(ax,ay) = scatter.getAxes()
ax.setMinValue(0.0).setMaxValue(1.0)
ay.setMinValue(0.0).setMaxValue(1.0)
legend = Legend(palette,400,legend_columns=2)
legend.setDiscreteMarkerStyle("circle")

d.add(legend)
d.connect(legend,"colour",scatter,"colour")
d.connect(scatter,"colour",legend,"colour")

(xaxis,yaxis) = scatter.getAxes()
xaxis.setStroke("red",3)
yaxis.setStroke("blue",3)
d.add(scatter)
html = d.draw(format="html")

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