root/tags/0.4.1/examples/scatterchart.py

Revision 112, 1.5 kB (checked in by lgs, 4 years ago)

Remove whitespace

Line 
1# Copyright (c) 2007-2008 by Lorenzo Gil Sanchez <lorenzo.gil.sanchez@gmail.com>
2#
3# This file is part of PyCha.
4#
5# PyCha is free software: you can redistribute it and/or modify
6# it under the terms of the GNU Lesser General Public License as published by
7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version.
9#
10# PyCha is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU Lesser General Public License for more details.
14#
15# You should have received a copy of the GNU Lesser General Public License
16# along with PyCha.  If not, see <http://www.gnu.org/licenses/>.
17
18import random
19import sys
20
21import cairo
22
23import pycha.scatter
24
25from lines import lines
26
27def scatterplotChart(output):
28    surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 400, 200)
29
30
31    dataSet = (
32        ('points', [(i, random.random() * 100.0) for i in range(100)]),
33        )
34
35    options = {
36        'background': {
37            'color': '#eeeeff',
38            'lineColor': '#444444'
39        },
40        'colorScheme': 'blue',
41        'legend': {
42            'hide': True,
43        },
44        'padding': {
45            'left': 55
46        }
47    }
48    chart = pycha.scatter.ScatterplotChart(surface, options)
49
50    chart.addDataset(dataSet)
51    chart.render()
52
53    surface.write_to_png(output)
54
55if __name__ == '__main__':
56    output = sys.argv[1] if len(sys.argv) > 1 else 'scatterchart.png'
57    scatterplotChart(output)
Note: See TracBrowser for help on using the browser.