colors
¤
default_colors
module-attribute
¤
default_colors = Colors(
{
"GASOLINE": "#808080",
"BIO_DIESEL": "#6B8E23",
"DIESEL": "#D3D3D3",
"URANIUM": "#66ff33",
"NG": "#FFD700",
"SNG": "#FFE100",
"LFO": "#8B008B",
"COAL": "#A0522D",
"HYDRO": "#00CED1",
"WASTE": "#FA8072",
"SOLAR": "#FFFF00",
"GEOTHERMAL": "#FF0000",
"H2": "#FF00FF",
"RES_WIND": "#FFA500",
"HEAT_HT": "#DC143C",
"ELECTRICITY": "#00BFFF",
"EUD_ELECTRICITY": "#00BFFF",
"ETHANOL": "#E1DA00",
"AMMONIA": "#C3DA00",
"METHANOL": "#A5DA00",
"DME": "#87DA00",
"CO2": "#545454",
"WOOD": "#CD853F",
"WET_BIOMASS": "#b37b44",
"PLANT": "#d4904e",
"HEAT": "#B51F1F",
"MOB": "#FF69B4",
"Electricity": "#00BFFF",
"Mobility": "#8B0000",
"Electric Infrastructure": "#000000",
"Gas Infrastructure": "#B22222",
"Wind": "#0000FF",
"WIND": "#0000FF",
"PV": "#FFD700",
"Geothermal": "#D3B9DA",
"Hydro River & Dam": "#008080",
"Industry": "#006400",
"Low Temperature Heat": "#FFA500",
"Hydro Storage": "#00CED1",
"Storage": "#ADD8E6",
"Electrolysis": "#66CDAA",
"Carbon Capture": "#A52A2A",
}
)
Default colors used in plots.
Color
¤
Color(color: str)
Utility class to represent colors.
Source code in src/energyscope/colors.py
13 14 |
|
cast
staticmethod
¤
Cast Color or str to Color.
Parameters:
Returns:
-
–
The argument itself if it is an instance of Color, a new instance of Color otherwise
Source code in src/energyscope/colors.py
16 17 18 19 20 21 22 23 24 25 26 27 28 |
|
rgba
¤
rgba(alpha: float = None)
Provides the RGBA representation of a color, using the given alpha
value when provided.
Parameters:
-
alpha
(float
, default:None
) –The alpha transparency value (0.0 to 1.0).
Returns:
-
str
–The RGBA color string in the format "rgba(r, g, b, a)".
Source code in src/energyscope/colors.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
|
Colors
¤
Colors(
colors: dict[str, Union[Color, str]] = None,
fallback: Union[Color, str] = fallback_color,
)
Utility class to represent a dict of Colors with fallback mechanism.
Colors can be accessed as in a regular dict.
If the key is not found, will try to fall back removing the text after the last underscore until it finds a match.
If no match can be found, energyscope.colors.fallback_color will be used.
colors['RES_WIND_ONSHORE'] will
- look for the key 'RES_WIND_ONSHORE' and return the corresponding value if exists
- if 'RES_WIND_ONSHORE' is not found, look for 'RES_WIND' and return the corresponding value if exists
- if 'RES_WIND' is not found, look for 'RES' and return the corresponding value if exists
- if 'RES' is not found, return energyscope.colors.fallback_color
Examples:
Examples should be written in doctest format, and should illustrate how to use the function.
>>> colors = Colors({"ELECTRICITY_LV": "#0000FF", "ELECTRICITY": "#FF0000"})
>>> print(colors["ELECTRICITY_LV"])
>>> print(colors["ELECTRICITY_OTHER"]) # will fall back to the color of "ELECTRICITY"
>>> print(colors["UNKNOWN"]) # will fall back to `fallback_color`
#0000FF
#FF0000
#000000
Source code in src/energyscope/colors.py
94 95 96 97 98 99 100 101 |
|
cast
staticmethod
¤
Cast Colors or dict to Colors.
Parameters:
Returns:
-
–
The argument itself if it is an instance of Colors, a new instance of Colors otherwise
Source code in src/energyscope/colors.py
119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
from_csv
staticmethod
¤
Creates a Colors object from a CSV file.
Parameters:
-
filepath
(str or Path
) –the path to the CSV file
The CSV file must contain the following columns: Name and Color.
All the others columns will be ignored.
Returns:
-
Colors
–the Colors object
Source code in src/energyscope/colors.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
|