<--previous | contents | next-->

# Scatter

Scatter Graph

GDChart provides the ability to add scatter points to any of the standard graph types. In PyGDChart, this is done by instantiating a number of Scatter objects, and adding them to a graph using the .setScatter() method.

## The Scatter Class

Scatter objects are instantiated as follows:

`

    x = Scatter(x, y, type, width, color)

`

- The x value should not exceed the number of points in the associated graph.
- type is one of "TRIANGLE_DOWN", "TRIANGLE_UP" and "CIRCLE", defaulting to "TRIANGLE_DOWN".
- width is a precentage defaulting to 100.
- color defaults to "white".

## Example

The graph at the head of this chapter was drawn using the following program:

`

    import random
    import gdchart

    sgraph = gdchart.Line()
    sgraph.width = 250
    sgraph.height = 250
    sgraph.sgraphtitle = "Weekday"
    sgraph.ytitle = "Percentage"
    sgraph.title = "Scatter"
    sgraph.plot_color = "red"
    sgraph.sgraphtitle_color = "white"
    sgraph.ytitle_color = "white"
    sgraph.setData(range(100))
    sgraph.setLabels(range(100))

    scats = []
    for i in range(150):
        x = random.randrange(30, 80)
        y = random.randrange(30, 80)
        s = gdchart.Scatter(x, y, "CIRCLE", 100, "blue")
        scats.append(s)
    sgraph.setScatter(scats)
    sgraph.draw("scatter.png")

`

<--previous | contents | next--> | (12/31/03)

PyGDChart User's Manual