bebi103.viz.q_to_color

bebi103.viz.q_to_color(x, colors, low=None, high=None, low_color='#808080', high_color='#808080', nan_color='#808080', scale='linear')

Convert a quantitative value to a color.

Parameters
  • x (int, float or array_like) – Value(s) for which colors are needed.

  • colors (list or tuple) – List of hex colors for mapping. E.g., bokeh.palettes.Viridis256.

  • low (int or float or None, default None) – Lowest quantitative value in color range. If None, take smallest entry in x. If x is scalar, low must not be None.

  • high (int or float or None, default None) – Highest quantitative value in color range. If None, take largest entry in x. If x is scalar, high must not be None.

  • low_color (str, default '#808080') – Hex value for color to be used for entries that are less than low. The default is gray.

  • high_color (str, default '#808080') – Hex value for color to be used for entries that are greater than high. The default is gray.

  • nan_color (str, default '#808080') – Hex value for color to be used for entries that are greater than high. The default is gray.

  • scale (str, default 'linear') – Scale of color map. Must be either ‘linear’ or ‘log’.

Returns

output – If x is scalar, then a single hex color is returned. Otherwise, a list of hex colors corresponding to the entries in x is returned.

Return type

str or list