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
- 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 }
- classmethod from_hex(hex_string)[source]¶
Create a color from a hex code.
- Parameters:
hex_string – Text string of a hex code given as #rrggbb.
- 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)
- 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 }
- 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>]
- 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 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 parula()[source]¶
Parula colors - the default of Matlab.
Parula was designed to be colorblind friendly .