forked from glumpy/glumpy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransform-linear-log-scale.py
42 lines (32 loc) · 1.3 KB
/
transform-linear-log-scale.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# -----------------------------------------------------------------------------
# Copyright (c) 2009-2016 Nicolas P. Rougier. All rights reserved.
# Distributed under the (new) BSD License.
# -----------------------------------------------------------------------------
import numpy as np
from glumpy import app
from glumpy.graphics.collections import PointCollection
from glumpy.transforms import LinearScale, LogScale, Position
window = app.Window(1024,1024, color=(1,1,1,1))
@window.event
def on_draw(dt):
window.clear()
points.draw()
# lin-lin
transform = Position(LinearScale('.xy', domain=(0,10)))
# log-lin
transform = Position(LogScale('.x', domain=(-1,1)),
LinearScale('.y', domain=(0,10)))
# lin-log
transform = Position(LinearScale('.x', domain=(0,10)),
LogScale('.y', domain=(-1,1)))
# log-log
# transform = Position(LogScale('.xy', domain=(-1,1)))
points = PointCollection("agg", transform = transform, color='local')
X = np.linspace(0.01,10.0,10000).reshape(10000,1)
Z = np.zeros((len(X),1))
points.append(np.hstack((X, X, Z)), color=(1,0,0,1))
points.append(np.hstack((X, np.log(X), Z)), color=(0,1,0,1))
points.append(np.hstack((X, 10**X, Z)), color=(0,0,1,1))
window.attach(points["transform"])
window.attach(points["viewport"])
app.run()