diff --git a/docs/.doctrees/environment.pickle b/docs/.doctrees/environment.pickle index 8b57732d..dc28055c 100644 Binary files a/docs/.doctrees/environment.pickle and b/docs/.doctrees/environment.pickle differ diff --git a/docs/.doctrees/main/cell_color.doctree b/docs/.doctrees/main/cell_color.doctree index 58836051..d456b1b1 100644 Binary files a/docs/.doctrees/main/cell_color.doctree and b/docs/.doctrees/main/cell_color.doctree differ diff --git a/docs/_sources/main/cell_color.rst.txt b/docs/_sources/main/cell_color.rst.txt index 3f4b1a21..a7b30eb5 100644 --- a/docs/_sources/main/cell_color.rst.txt +++ b/docs/_sources/main/cell_color.rst.txt @@ -10,18 +10,16 @@ must return a RGBA array (0-255) or a standard color name. # set a continuous colormap to the "sepal_length" column @table.foreground_colormap("sepal_length") - def f(v): - i = (v - 4) / 4 - return [255, 0, int(255 * i), 255] + def _(x: float): + red = np.array([255, 0, 0, 255], dtype=np.uint8) + blue = np.array([0, 0, 255, 255], dtype=np.uint8) + return (x - lmin) / lrange * blue + (lmax - x) / lrange * red .. code-block:: python # set a discrete colormap to the "sepal_width" column @table.background_colormap("sepal_width") - def f(v): - if v < 3.2: - return "green" - else: - return "purple" + def _(x: float): + return "green" if x < 3.2 else "violet" .. image:: ../fig/colormap.png diff --git a/docs/main/cell_color.html b/docs/main/cell_color.html index 23c539ac..983df39e 100644 --- a/docs/main/cell_color.html +++ b/docs/main/cell_color.html @@ -91,18 +91,16 @@
# set a continuous colormap to the "sepal_length" column
@table.foreground_colormap("sepal_length")
-def f(v):
- i = (v - 4) / 4
- return [255, 0, int(255 * i), 255]
+def _(x: float):
+ red = np.array([255, 0, 0, 255], dtype=np.uint8)
+ blue = np.array([0, 0, 255, 255], dtype=np.uint8)
+ return (x - lmin) / lrange * blue + (lmax - x) / lrange * red
# set a discrete colormap to the "sepal_width" column
@table.background_colormap("sepal_width")
-def f(v):
- if v < 3.2:
- return "green"
- else:
- return "purple"
+def _(x: float):
+ return "green" if x < 3.2 else "violet"