source: qesdi/linplot/trunk/tests/linplot_tests/draw/common.py @ 6446

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/qesdi/linplot/trunk/tests/linplot_tests/draw/common.py@6446
Revision 6446, 756 bytes checked in by pnorton, 11 years ago (diff)

Made several changes to try and improve the layout of the plot. Also introduced rotating axis labels to avoid labels being drawn on top of each other.

Line 
1'''
2Created on 29 Jan 2010
3
4@author: pnorton
5'''
6
7import random
8import time
9import numpy
10
11def getData(n):
12   
13    x = random.random() * 100.0
14    l = [x]
15   
16    for i in range(n - 1):
17        x += random.random() * 100.0 - 50.0
18        l.append(x)
19       
20    return numpy.array(l)
21
22characters = [chr(x) for x in range(32, 126)]
23characters += [' ' for x in range(10)] # make spaces a bit more likely
24characters.pop(characters.index('$'))
25
26def seed(newSeed=None):
27    if newSeed is None:
28        s = hash(time.time())
29    else:
30        s = newSeed
31       
32    print "Seed:", s
33    random.seed(s)
34    return s
35
36def getLabel(min, max):
37    n = random.randint(min, max)
38    label = ''.join([random.choice(characters) for x in range(n)])
39    return label
40
Note: See TracBrowser for help on using the repository browser.