color
sleap.gui.color
¶
Logic for determining what color/width to draw instance nodes/edges.
The color can be determined by the current color palette as well as settings
on the ColorManager object:
- distinctly_color: "instances", "nodes", or "edges"
- color_predicted: whether to use colors for predicted instances, or just plot them in yellow/grey
Initial color palette (and other settings, like default line width) is read from user preferences but can be changed after object is created.
Classes:
| Name | Description |
|---|---|
ColorManager |
Class to determine color to use for track. |
ColorManager
¶
Class to determine color to use for track.
The color depends on the order of the tracks in Labels object,
so we need to initialize with Labels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
labels
|
Labels
|
The :class: |
None
|
palette
|
str
|
String with the color palette name to use. |
'standard'
|
Methods:
| Name | Description |
|---|---|
color_to_tuple |
Convert and ensure color is (r, g, b)-tuple. |
fix_index |
Returns an index within range of color palette. |
get_color_by_idx |
Returns color tuple corresponding to item index. |
get_item_color |
Gets (r, g, b) tuple of color to use for drawing item. |
get_item_pen_width |
Gets width of pen to use for drawing item. |
get_item_type_pen_width |
Gets pen width to use for given item type (as string). |
get_pseudo_track_index |
Returns an index for giving track colors to instances without track. |
get_track_color |
Returns the color to use for a given track. |
is_edge |
Returns whether item is an edge, i.e., pair of nodes. |
is_node |
Returns whether item is a node, i.e., Node or node name. |
is_predicted |
Returns whether instance is predicted. |
is_sequence |
Returns whether item is a tuple or list. |
set_palette |
Functional alias for palette property setter. |
Attributes:
| Name | Type | Description |
|---|---|---|
labels |
Gets or sets labels dataset for which we are coloring tracks. |
|
palette |
Gets or sets palette (by name). |
|
palette_names |
Iterable[Text]
|
Gets list of palette names. |
tracks |
Iterable[Track]
|
Gets tracks for project. |
Source code in sleap/gui/color.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | |
labels
property
writable
¶
Gets or sets labels dataset for which we are coloring tracks.
palette
property
writable
¶
Gets or sets palette (by name).
palette_names
property
¶
Gets list of palette names.
tracks
property
¶
Gets tracks for project.
color_to_tuple(color)
staticmethod
¶
Convert and ensure color is (r, g, b)-tuple.
Source code in sleap/gui/color.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
fix_index(idx)
¶
Returns an index within range of color palette.
Source code in sleap/gui/color.py
118 119 120 | |
get_color_by_idx(idx)
¶
Returns color tuple corresponding to item index.
Source code in sleap/gui/color.py
122 123 124 125 | |
get_item_color(item, parent_instance=None, parent_skeleton=None)
¶
Gets (r, g, b) tuple of color to use for drawing item.
Source code in sleap/gui/color.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | |
get_item_pen_width(item, parent_instance=None)
¶
Gets width of pen to use for drawing item.
Source code in sleap/gui/color.py
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | |
get_item_type_pen_width(item_type)
¶
Gets pen width to use for given item type (as string).
Source code in sleap/gui/color.py
233 234 235 236 237 238 239 240 241 242 243 244 | |
get_pseudo_track_index(instance, frame=None)
¶
Returns an index for giving track colors to instances without track.
Source code in sleap/gui/color.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
get_track_color(track)
¶
Returns the color to use for a given track.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
track
|
Union[Track, int]
|
|
required |
Source code in sleap/gui/color.py
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | |
is_edge(item)
classmethod
¶
Returns whether item is an edge, i.e., pair of nodes.
Source code in sleap/gui/color.py
192 193 194 195 196 197 198 199 200 | |
is_node(item)
staticmethod
¶
Returns whether item is a node, i.e., Node or node name.
Source code in sleap/gui/color.py
202 203 204 205 | |
is_predicted(instance)
staticmethod
¶
Returns whether instance is predicted.
Source code in sleap/gui/color.py
207 208 209 210 | |
is_sequence(item)
classmethod
¶
Returns whether item is a tuple or list.
Source code in sleap/gui/color.py
187 188 189 190 | |
set_palette(palette)
¶
Functional alias for palette property setter.
Source code in sleap/gui/color.py
114 115 116 | |