44
55from __future__ import absolute_import , division , print_function , unicode_literals
66
7+ import numpy as np
8+
79class ColorScale :
810 '''
911 A color scale class to map scalar values to rgb colors. The class allows
@@ -81,15 +83,15 @@ def __call__(self, val):
8183 return self .colorTics [int ((float (val ) - self .min )
8284 / self .span * self .size )]
8385
84- def set_background_color (color ):
86+ def set_background_color (self , color ):
8587 '''Sets RGB color used for values below the scale minimum.
8688
8789 Arguments:
8890
8991 `color` (3-tuple): An RGB triplet
9092 '''
9193 if type (color ) in (list , tuple ):
92- color = array (color )
94+ color = np . array (color )
9395 if len (color .shape ) != 1 or color .shape [0 ] != 3 :
9496 raise 'Color value must be have exactly 3 elements.'
9597 self .bgColor = color
@@ -115,18 +117,17 @@ def create_default_color_scale(ntics=0):
115117 Total number of colors in the scale. If this value is 0, no
116118 interpolated colors will be used.
117119 '''
118- from numpy import array
119- mycolors = array ([[0 , 0 , 0 ],
120- [0 , 0 , 255 ],
121- [0 , 255 , 0 ],
122- [255 , 0 , 0 ],
123- [255 , 255 , 0 ],
124- [255 , 255 , 255 ]])
120+ mycolors = np .array ([[0 , 0 , 0 ],
121+ [0 , 0 , 255 ],
122+ [0 , 255 , 0 ],
123+ [255 , 0 , 0 ],
124+ [255 , 255 , 0 ],
125+ [255 , 255 , 255 ]])
125126
126127 if ntics != 0 and ntics < len (mycolors ):
127128 raise ValueError ('Any non-zero value of `ntics` must be greater than'
128129 ' {}.' .format (len (mycolors )))
129- levels = array ([0. , 10. , 20. , 30. , 40. , 50. ])
130+ levels = np . array ([0. , 10. , 20. , 30. , 40. , 50. ])
130131 scale = ColorScale (levels , mycolors , ntics )
131132 return scale
132133
0 commit comments