ladybug.color module

Ladybug color, colorsets and colorrange.

class ladybug.color.Color(r=0, g=0, b=0, a=255)[source]

Bases: object

Ladybug RGBA color.

Parameters
  • r – red value 0-255, default: 0

  • g – green value 0-255, default: 0

  • b – blue red value 0-255, default: 0

  • a – alpha value 0-255. Alpha defines the opacity as a number between 0 (fully transparent) and 255 (fully opaque). Default 255.

Properties:
  • r

  • g

  • b

  • a

ToString()[source]

Overwrite .NET ToString.

duplicate()[source]

Return a copy of the current color.

classmethod from_dict(data)[source]

Create a color from a dictionary.

Parameters

data – A python dictionary in the following format

{
"r": 255,
"g": 0,
"b": 150,
"a": 255
}
to_dict()[source]

Get color as a dictionary.

property a

Return A value.

property b

Return B value.

property g

Return G value.

property r

Return R value.

class ladybug.color.ColorRange(colors=None, domain=None, continuous_colors=True)[source]

Bases: object

Ladybug Color Range. Used to generate colors from numerical values.

Parameters
  • colors – A list of colors. Colors should be input as objects with R, G, B values. Default is Ladybug’s original colorset.

  • domain – A list of at least two numbers to set the lower and upper boundary of the color range. This can also be a list of more than two values, which can be used to approximate logarithmic or other types of color scales. However, the number of values in the domain must always be less than or equal to the number of colors. Default: [0, 1].

  • continuous_colors – Boolean. If True, the colors generated from the color range will be in a continuous gradient. If False, they will be categorized in incremental groups according to the number_of_segments. Default: True for continuous colors.

Properties:
  • colors

  • continuous_colors

  • domain

Usage:

1.
    color_range = ColorRange(continuous_colors=False)
    color_range.domain = [100, 2000]
    color_range.colors = [Color(75, 107, 169), Color(245, 239, 103),
        Color(234, 38, 0)]
    print(color_range.color(99))
    print(color_range.color(100))
    print(color_range.color(2000))
    print(color_range.color(2001))
    >> (R:75, G:107, B:169)
    >> (R:245, G:239, B:103)
    >> (R:245, G:239, B:103)
    >> (R:234, G:38, B:0)

2.
    color_range = ColorRange(continuous_colors=False)
    color_range.domain = [100, 2000]
    color_range.colors = [Color(75, 107, 169), Color(245, 239, 103),
        Color(234, 38, 0)]
    color_range.color(300)
    >> (R:245, G:239, B:103)
ToString()[source]

Overwrite .NET ToString.

color(value)[source]

Calculate a color along the range for an input value.

duplicate()[source]

Return a copy of the current color range.

classmethod from_dict(data)[source]

Create a color range from a dictionary.

Parameters

data – A python dictionary in the following format

{
"colors": [{'r': 0, 'g': 0, 'b': 0}, {'r': 255, 'g': 255, 'b': 255}],
"domain": [0, 100],
"continuous_colors": True
}
to_dict()[source]

Get color range as a dictionary.

property colors

Get or set the colors defining the color range.

property continuous_colors

Boolean noting whether colors generated are continuous or discrete.

property domain

Get or set the domain defining the color range.

class ladybug.color.Colorset[source]

Bases: object

Ladybug Color-range repository.

Note that the colorblind friendly schemes have prioritized readability for red-green colorblindness (deuteranomaly, protanomaly, protanopia, and deuteranopia), which is by far more common than blue-yellow colorblindness. However, they are not necessarily ideal for all types of color blindness, though they are monotonic and perceptually uniform to all forms of color vision. This means that they should be readable as a dark-to-light scale by anyone.

A list of default Ladybug colorsets for color range:
  • 0 - Original Ladybug

  • 1 - Nuanced Ladybug

  • 2 - Multi-colored Ladybug

  • 3 - Ecotect

  • 4 - View Study

  • 5 - Shadow Study

  • 6 - Glare Study

  • 7 - Annual Comfort

  • 8 - Thermal Comfort

  • 9 - Peak Load Balance

  • 10 - Heat Sensation

  • 11 - Cold Sensation

  • 12 - Benefit/Harm

  • 13 - Harm

  • 14 - Benefit

  • 15 - Shade Benefit/Harm

  • 16 - Shade Harm

  • 17 - Shade Benefit

  • 18 - Energy Balance

  • 19 - Energy Balance w/ Storage

  • 20 - THERM

  • 21 - Cloud Cover

  • 22 - Black to White

  • 23 - Blue, Green, Red

  • 24 - Multicolored 2

  • 25 - Multicolored 3

  • 26 - OpenStudio Palette

  • 27 - Cividis (colorblind friendly)

  • 28 - Viridis (colorblind friendly)

  • 29 - Parula (colorblind friendly)

Usage:

# initialize colorsets
cs = Colorset()
print(cs[0])
>> [<R:75, G:107, B:169>, <R:115, G:147, B:202>, <R:170, G:200, B:247>,
    <R:193, G:213, B:208>, <R:245, G:239, B:103>, <R:252, G:230, B:74>,
    <R:239, G:156, B:21>, <R:234, G:123, B:0>, <R:234, G:74, B:0>,
    <R:234, G:38, B:0>]
ToString()[source]

Overwrite .NET ToString.

classmethod annual_comfort()[source]

Good for annual metrics like UDI and thermal comfort percent.

classmethod benefit()[source]

Benefit colors (light yellow to green).

classmethod benefit_harm()[source]

Benefit / harm study colors (red to light yellow to green).

classmethod black_to_white()[source]

Black to white colors.

classmethod blue_green_red()[source]

Blue to Green to Red colors.

classmethod cividis()[source]

Cividis colors, which were designed to be colorblind friendly.

classmethod cloud_cover()[source]

Cloud cover colors.

classmethod cold_sensation()[source]

Blue colors for cold sensation.

classmethod ecotect()[source]

Ecotect colors, also known to some as Plasma.

classmethod energy_balance()[source]

Energy Balance colors.

classmethod energy_balance_storage()[source]

Energy Balance colors with a brown color for storage term.

classmethod glare_study()[source]

Useful for depicting spatial glare (light blue to yellow, red, black).

classmethod harm()[source]

Harm colors (light yellow to red).

classmethod heat_sensation()[source]

Red colors for heat sensation.

classmethod multi_colored()[source]

Multi-colored legend.

classmethod multicolored_2()[source]

Multi-colored colors with less saturation.

classmethod multicolored_3()[source]

Multi-colored colors with the least saturation.

classmethod nuanced()[source]

Nuanced Ladybug colors.

classmethod openstudio_palette()[source]

Standard color set for the OpenStudio surface types. Ordered as follows.

Exterior Wall, Interior Wall, Underground Wall, Roof, Ceiling, Underground Roof, Exposed Floor, Interior Floor, Ground Floor, Window, Door, Shade, Air

classmethod original()[source]

Original Ladybug colors.

classmethod parula()[source]

Parula colors - the default of Matlab.

Parula was designed to be colorblind friendly .

classmethod peak_load_balance()[source]

Colors for the typical terms of a peak load balance.

classmethod shade_benefit()[source]

Shade benefit colors (white to dark blue).

classmethod shade_benefit_harm()[source]

Shade benefit / harm colors (dark red to white to dark blue).

classmethod shade_harm()[source]

Shade harm colors (white to dark red).

classmethod shadow_study()[source]

Shadow study colors (dark to light grey).

classmethod therm()[source]

THERM colors.

classmethod thermal_comfort()[source]

Thermal comfort colors (blue to white to red).

classmethod view_study()[source]

View analysis colors.

classmethod viridis()[source]

Viridis colors, which were designed to be colorblind friendly.