-
-
Notifications
You must be signed in to change notification settings - Fork 179
Expand file tree
/
Copy pathlinear_scale.py
More file actions
38 lines (33 loc) · 1.68 KB
/
linear_scale.py
File metadata and controls
38 lines (33 loc) · 1.68 KB
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
# -----------------------------------------------------------------------------
# Copyright (c) 2009-2016 Nicolas P. Rougier. All rights reserved.
# Distributed under the (new) BSD License.
# -----------------------------------------------------------------------------
import numpy as np
from glumpy import library
from . transform import Transform
from . quantitative_scale import QuantitativeScale
class LinearScale(QuantitativeScale):
"""
Linear scales are the most common scale, and a good default choice to map a
continuous input domain to a continuous output range. The mapping is linear
in that the output range value y can be expressed as a linear function of
the input domain value x: y = mx + b. The input domain is typically a
dimension of the data that you want to visualize, such as the height of
students (measured in meters) in a sample population. The output range is
typically a dimension of the desired output visualization, such as the
height of bars (measured in pixels) in a histogram.
:param 2-tuple domain: Input domains. Default is (-1,+1).
:param 2-tuple range: Output range. Default is (-1,+1).
:param bool clamp: Clamping test. Default is False.
:param bool discard: Discard test. Default is True.
"""
aliases = { "domain" : "linear_scale_domain",
"range" : "linear_scale_range",
"clamp" : "linear_scale_clamp",
"discard" : "linear_scale_discard" }
def __init__(self, *args, **kwargs):
"""
Initialize the transform.
"""
code = library.get("transforms/linear-scale.glsl")
QuantitativeScale.__init__(self, code, *args, **kwargs)