Skip to content

make_color_list

jaybgager edited this page Oct 5, 2026 · 2 revisions

This function generates a list of hexadecimal values spread roughly evenly around a hue wheel based on the number requested. Useful for programmatically generating links for comparing groups of segments that need to be differentiated visually.

Arguments:

  • number_of_colors (integer, mandatory)
    • the number of segments you need colors for
  • alternate_brightness (float, optional, default=0.0)
    • value between 0 and 1 indicating how much to vary the brightness of neighboring colors
    • values close 0 will produce mild variation, those near 1 will approach black and white
    • only affects lists of 11 or more colors, lower numbers use manually-chosen color lists

Returns:

  • colors (list of strings)
    • a list of the requested number of hue-wheel-spaced hexadecimal values

Examples

Default Behavior

INPUT:

import tracertools as tt

hex_colors = tt.make_color_list(
    number_of_colors = 6,
)

print(hex_colors)

OUTPUT:

[
    '#FF5533', 
    '#FF9C33', 
    '#FFDD33', 
    '#A8FFA8', 
    '#469FE3', 
    '#CC85FF'
]

This produces the following colors:

color_list_example_01

These colors may seem light in value, particularly the green, but they're chosen for use on neuroglancer segments against a black background. The lighter value helps show surface definition with neuroglancer's default lighting engine.

Alternating Brightness

INPUT:

import tracertools as tt

hex_colors = tt.make_color_list(
    number_of_colors = 20,
    alternate_brightness = 0.4,
)

print(hex_colors)

OUTPUT:

[
    '#990000', 
    '#ff9366', 
    '#995b00', 
    '#ffee66', 
    '#7b9900', 
    '#b4ff66', 
    '#209900', 
    '#66ff73', 
    '#00993a', 
    '#66ffce', 
    '#009996', 
    '#66d4ff', 
    '#004099', 
    '#6679ff', 
    '#1a0099', 
    '#ae66ff', 
    '#750099', 
    '#ff66f4', 
    '#990061', 
    '#ff6699'
]

This produces the following colors:

color_list_example_02

Note

Large requests (~30+) can result in nearby colors becoming difficult to distinguish. Using odd numbers with the alternate_brightness feature results in the first color's brightness not being adjusted to avoid adjusting it in the same direction as either of its neighbors. The maximum number of hues this function can produce is 1530.

Clone this wiki locally