|
|
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.
Scatter objects are instantiated as follows:
x = Scatter(x, y, type, width, color)
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