tracktable.render.map_decoration.coloring module

Module contents

tracktable.render.coloring - Collection of functions for coloring trajectories

tracktable.render.map_decoration.coloring.get_color_mapper(color_scale, color_map)[source]
Returns an object that can translate scalars into colors

Returns an object that can produce for any scalar the correct RGBA color from the given color_map using the given color_scale.

Parameters
  • color_scale (matplotlib.colors.Normalize() or LogNorm()) – Linear or logarithmic scale

  • matplotlib (color_map (name of standard colormap as string or) – color_map object or list of either): The color map to use in rendering the segments of each trajectory.

Returns

An object that can translate scalars into colors and an object that can produce for any scalar the correct RGBA color from the given color_map using the given color_scale.

tracktable.render.map_decoration.coloring.get_constant_color_cmap(color)[source]

Returns a colormap containing the single color given

Parameters

color (str) – Color to get colormap from

Returns

Returns a colormap containing the single color given

tracktable.render.map_decoration.coloring.hue_gradient_cmap(hue, chop_frac=0.29)[source]
Returns a color map which progresses from dark to light given a

specific hue

Parameters
  • hue (str or float) – the hue to generate the color map for. (0 to 1)

  • chop_frac (float) – the fraction of the beginning and end of the total gradient to chop off so as to not be too light or dark.

Returns

color map object which can be passed to matplotlib’s cmap param

or render_trajectories color_map

tracktable.render.map_decoration.coloring.matplotlib_cmap_to_dict(colormap_name, num_colors=16)[source]

Convert a Matplotlib colormap into a dict for Folium

Folium expects its color maps as a dictionary whose keys are floats between zero and one and whose values are the color to which that value should be mapped.

Parameters

colormap_name (string) – Name of one of Matplotlib’s built-in color maps.

Keyword Arguments

num_colors (int) – How many entries to put into the output. Defaults to 16.

Returns

Colormap in dictionary format

Raises

ValueError – no such color map exists

Note

It would be easy to extend this function to fit the color map to a range other than [0, 1] or to make it use a logarithmic scale (or any other scale) instead of linear. Ask, or just do it, if you’d like this.

tracktable.render.map_decoration.coloring.random_color()[source]

Returns a random RGB color in hex string format

tracktable.render.map_decoration.coloring.random_hue()[source]

Returns a random hue value (0 to 1)

tracktable.render.map_decoration.coloring.setup_colors(line_color, color_map, gradient_hue, point_color, color_scale, objid, i, linewidth_generator)[source]

Processes the color optins and returns the current color maps This function determines what the current color map should be for lines and points given the various releated parameters and returns color maps for points and for lines.

Parameters
  • string (hex color) – or matplotlib color object, or list of any of these): The single color to use for all the segments in each trajectory. Overrides color_map and gradient_hue values. Can be a list of matplotlib color name strings, hex color strings or matplotlib color objects the same length as the length of the list of trajectories.

  • string – or matplotlib color object, or list of any of these): The single color to use for all the segments in each trajectory. Overrides color_map and gradient_hue values. Can be a list of matplotlib color name strings, hex color strings or matplotlib color objects the same length as the length of the list of trajectories.

  • matplotlib (color_map (name of standard colormap as string or) – color_map object or list of either): The color map to use in rendering the segments of each trajectory.

  • gradient_hue (float or list of floats) – hue or list of hues (one per trajectory) to be used in definig the gradient color map (dark to light) for the trajectories. Only used if line_color and color_map are not used (set to ‘’). If line_color, color_map and gradient_hue are all unset the default behavior is to set the gradient_hue based on a hash of the object_id

  • string – or matplotlib color object, or list of any of these): The single color to use for all the points in each trajectory. Can be a list of matplotlib color name strings, hex color strings or matplotlib color objects the same length as the length of the list of trajectories. If not specified, the color matches the segment incident at the point.

  • string – or matplotlib color object, or list of any of these): The single color to use for all the points in each trajectory. Can be a list of matplotlib color name strings, hex color strings or matplotlib color objects the same length as the length of the list of trajectories. If not specified, the color matches the segment incident at the point.

  • color_scale (matplotlib.colors.Normalize() or LogNorm()) – Linear or logarithmic scale

  • objid (str) – ID used for MD5 Hash

  • i (int) – Index for lists

  • linewidth_generator (function) – Function to generate linewidths

Returns

Current color maps