Visualization¶
flyvision.analysis.visualization.figsize_utils¶
Functions¶
flyvision.analysis.visualization.figsize_utils.figsize_from_n_items ¶
figsize_from_n_items(
n_panels,
max_figure_height_cm=22,
panel_height_cm=3,
max_figure_width_cm=18,
panel_width_cm=3.6,
dw_cm=0.1,
)
Calculate figure size based on the number of panels.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_panels |
int
|
Number of panels in the figure. |
required |
max_figure_height_cm |
float
|
Maximum figure height in centimeters. |
22
|
panel_height_cm |
float
|
Height of each panel in centimeters. |
3
|
max_figure_width_cm |
float
|
Maximum figure width in centimeters. |
18
|
panel_width_cm |
float
|
Width of each panel in centimeters. |
3.6
|
dw_cm |
float
|
Decrement width in centimeters for panel size adjustment. |
0.1
|
Returns:
Name | Type | Description |
---|---|---|
FigsizeCM |
FigsizeCM
|
Calculated figure size. |
Source code in flyvision/analysis/visualization/figsize_utils.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
|
flyvision.analysis.visualization.figsize_utils.figure_size_cm ¶
figure_size_cm(
n_panel_rows,
n_panel_columns,
max_figure_height_cm=22,
panel_height_cm=3,
max_figure_width_cm=18,
panel_width_cm=3.6,
allow_rearranging=True,
)
Calculate figure size in centimeters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_panel_rows |
int
|
Number of panel rows. |
required |
n_panel_columns |
int
|
Number of panel columns. |
required |
max_figure_height_cm |
float
|
Maximum figure height in centimeters. |
22
|
panel_height_cm |
float
|
Height of each panel in centimeters. |
3
|
max_figure_width_cm |
float
|
Maximum figure width in centimeters. |
18
|
panel_width_cm |
float
|
Width of each panel in centimeters. |
3.6
|
allow_rearranging |
bool
|
Whether to allow rearranging panels. |
True
|
Returns:
Name | Type | Description |
---|---|---|
FigsizeCM |
FigsizeCM
|
Calculated figure size. |
Raises:
Type | Description |
---|---|
ValueError
|
If the figure size is not realizable under given constraints. |
Source code in flyvision/analysis/visualization/figsize_utils.py
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 |
|
flyvision.analysis.visualization.figsize_utils.fit_panel_size ¶
fit_panel_size(
n_panel_rows,
n_panel_columns,
max_figure_height_cm=22,
panel_height_cm=3,
max_figure_width_cm=18,
panel_width_cm=3.6,
dw_cm=0.1,
allow_rearranging=True,
)
Fit panel size to figure constraints.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_panel_rows |
int
|
Number of panel rows. |
required |
n_panel_columns |
int
|
Number of panel columns. |
required |
max_figure_height_cm |
float
|
Maximum figure height in centimeters. |
22
|
panel_height_cm |
float
|
Height of each panel in centimeters. |
3
|
max_figure_width_cm |
float
|
Maximum figure width in centimeters. |
18
|
panel_width_cm |
float
|
Width of each panel in centimeters. |
3.6
|
dw_cm |
float
|
Decrement width in centimeters for panel size adjustment. |
0.1
|
allow_rearranging |
bool
|
Whether to allow rearranging panels. |
True
|
Returns:
Name | Type | Description |
---|---|---|
FigsizeCM |
FigsizeCM
|
Fitted figure size. |
Source code in flyvision/analysis/visualization/figsize_utils.py
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 |
|
flyvision.analysis.visualization.figsize_utils.cm_to_inch ¶
cm_to_inch(*args)
Convert centimeters to inches.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args |
Union[Tuple[float, float], float]
|
Either a tuple of (width, height) or separate width and height values. |
()
|
Returns:
Type | Description |
---|---|
Tuple[float, float]
|
Tuple of width and height in inches. |
Source code in flyvision/analysis/visualization/figsize_utils.py
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
|
Classes¶
flyvision.analysis.visualization.figsize_utils.FigsizeCM
dataclass
¶
Represents figure size in centimeters.
Attributes:
Name | Type | Description |
---|---|---|
n_rows |
int
|
Number of rows in the figure. |
n_columns |
int
|
Number of columns in the figure. |
height |
float
|
Height of the figure in centimeters. |
width |
float
|
Width of the figure in centimeters. |
pad |
float
|
Padding in centimeters. |
Source code in flyvision/analysis/visualization/figsize_utils.py
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 |
|
axis_grid ¶
axis_grid(
projection=None,
as_matrix=False,
fontsize=5,
wspace=0.1,
hspace=0.3,
alpha=1,
unmask_n=None,
)
Create an axis grid for the figure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
projection |
Union[str, None]
|
Type of projection for the axes. |
None
|
as_matrix |
bool
|
Whether to return axes as a matrix. |
False
|
fontsize |
int
|
Font size for the axes. |
5
|
wspace |
float
|
Width space between subplots. |
0.1
|
hspace |
float
|
Height space between subplots. |
0.3
|
alpha |
float
|
Alpha value for the axes. |
1
|
unmask_n |
Union[int, None]
|
Number of axes to unmask. |
None
|
Returns:
Type | Description |
---|---|
Tuple
|
Tuple containing the figure and axes. |
Source code in flyvision/analysis/visualization/figsize_utils.py
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 |
|
flyvision.analysis.visualization.network_fig¶
Classes¶
flyvision.analysis.visualization.network_fig.WholeNetworkFigure ¶
Class for creating a whole network figure.
Attributes:
Name | Type | Description |
---|---|---|
nodes |
DataFrame
|
DataFrame containing node information. |
edges |
DataFrame
|
DataFrame containing edge information. |
layout |
Dict[str, str]
|
Dictionary mapping node types to layout positions. |
cell_types |
List[str]
|
List of unique cell types. |
video |
bool
|
Whether to include video node. |
rendering |
bool
|
Whether to include rendering node. |
motion_decoder |
bool
|
Whether to include motion decoder node. |
decoded_motion |
bool
|
Whether to include decoded motion node. |
pixel_accurate_motion |
bool
|
Whether to include pixel-accurate motion node. |
Source code in flyvision/analysis/visualization/network_fig.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 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 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 |
|
init_figure ¶
init_figure(
figsize=[15, 6],
fontsize=6,
decoder_box=True,
cell_type_labels=True,
neuropil_labels=True,
network_layout_axes_kwargs={},
add_graph_kwargs={},
)
Initialize the figure with various components.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
figsize |
List[int]
|
Size of the figure. |
[15, 6]
|
fontsize |
int
|
Font size for labels. |
6
|
decoder_box |
bool
|
Whether to add a decoder box. |
True
|
cell_type_labels |
bool
|
Whether to add cell type labels. |
True
|
neuropil_labels |
bool
|
Whether to add neuropil labels. |
True
|
network_layout_axes_kwargs |
Dict
|
Additional kwargs for network_layout_axes. |
{}
|
add_graph_kwargs |
Dict
|
Additional kwargs for add_graph. |
{}
|
Source code in flyvision/analysis/visualization/network_fig.py
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 |
|
add_graph ¶
add_graph(
edge_color_key=None,
arrows=True,
edge_alpha=1.0,
edge_width=1.0,
constant_edge_width=0.25,
constant_edge_color="#c5c5c5",
edge_cmap=None,
nx_kwargs={},
)
Add the graph to the figure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
edge_color_key |
Optional[str]
|
Key for edge color. |
None
|
arrows |
bool
|
Whether to add arrows to edges. |
True
|
edge_alpha |
float
|
Alpha value for edges. |
1.0
|
edge_width |
float
|
Width of edges. |
1.0
|
constant_edge_width |
Optional[float]
|
Constant width for all edges. |
0.25
|
constant_edge_color |
str
|
Constant color for all edges. |
'#c5c5c5'
|
edge_cmap |
Optional[str]
|
Colormap for edges. |
None
|
nx_kwargs |
Dict
|
Additional kwargs for networkx drawing. |
{}
|
Source code in flyvision/analysis/visualization/network_fig.py
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 |
|
Functions¶
flyvision.analysis.visualization.network_fig.network_layout_axes ¶
network_layout_axes(
layout,
cell_types=None,
fig=None,
figsize=[16, 10],
types_per_column=8,
region_spacing=2,
wspace=0,
hspace=0,
as_dict=False,
pos=None,
)
Create axes for network layout.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layout |
Dict[str, str]
|
Dictionary mapping node types to layout positions. |
required |
cell_types |
Optional[List[str]]
|
List of cell types to include. |
None
|
fig |
Optional[Figure]
|
Existing figure to use. |
None
|
figsize |
List[int]
|
Size of the figure. |
[16, 10]
|
types_per_column |
int
|
Number of types per column. |
8
|
region_spacing |
int
|
Spacing between regions. |
2
|
wspace |
float
|
Width space between subplots. |
0
|
hspace |
float
|
Height space between subplots. |
0
|
as_dict |
bool
|
Whether to return axes as a dictionary. |
False
|
pos |
Optional[Dict[str, List[float]]]
|
Pre-computed positions for nodes. |
None
|
Returns:
Type | Description |
---|---|
Tuple[Figure, Union[List[Axes], Dict[str, Axes]], Dict[str, List[float]]]
|
Tuple containing the figure, axes, and node positions. |
Source code in flyvision/analysis/visualization/network_fig.py
465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 |
|
flyvision.analysis.visualization.network_fig._network_graph_node_pos ¶
_network_graph_node_pos(
layout, region_spacing=2, types_per_column=8
)
Compute (x, y) coordinates for nodes in a network graph.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layout |
Dict[str, str]
|
Dictionary mapping node types to layout positions. |
required |
region_spacing |
float
|
Spacing between regions. |
2
|
types_per_column |
int
|
Number of types per column. |
8
|
Returns:
Type | Description |
---|---|
Dict[str, List[float]]
|
Dictionary mapping node types to their (x, y) coordinates. |
Note
Special nodes like ‘video’, ‘rendering’, etc. are positioned at the middle y-coordinate of their respective columns.
Source code in flyvision/analysis/visualization/network_fig.py
534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 |
|
flyvision.analysis.visualization.plots¶
Functions¶
flyvision.analysis.visualization.plots.heatmap ¶
heatmap(
matrix,
xlabels,
ylabels=None,
size_scale="auto",
cmap=cm.get_cmap("seismic"),
origin="upper",
ax=None,
fig=None,
vmin=None,
vmax=None,
symlog=None,
cbar_label="",
log=None,
cbar_height=0.5,
cbar_width=0.01,
title="",
figsize=[5, 4],
fontsize=4,
midpoint=None,
cbar=True,
grid_linewidth=0.5,
**kwargs
)
Create a heatmap scatter plot of the matrix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
matrix |
ndarray
|
2D matrix to be plotted. |
required |
xlabels |
List[str]
|
List of x-axis labels. |
required |
ylabels |
Optional[List[str]]
|
List of y-axis labels. If not provided, xlabels will be used. |
None
|
size_scale |
Union[str, float]
|
Size scale of the scatter points. If “auto”, uses 0.005 * prod(figsize). |
'auto'
|
cmap |
Colormap
|
Colormap for the heatmap. |
get_cmap('seismic')
|
origin |
Literal['upper', 'lower']
|
Origin of the matrix. Either “upper” or “lower”. |
'upper'
|
ax |
Optional[Axes]
|
Existing Matplotlib Axes object to plot on. |
None
|
fig |
Optional[Figure]
|
Existing Matplotlib Figure object to use. |
None
|
vmin |
Optional[float]
|
Minimum value for color scaling. |
None
|
vmax |
Optional[float]
|
Maximum value for color scaling. |
None
|
symlog |
Optional[bool]
|
Whether to use symmetric log normalization. |
None
|
cbar_label |
str
|
Label for the colorbar. |
''
|
log |
Optional[bool]
|
Whether to use logarithmic color scaling. |
None
|
cbar_height |
float
|
Height of the colorbar. |
0.5
|
cbar_width |
float
|
Width of the colorbar. |
0.01
|
title |
str
|
Title of the plot. |
''
|
figsize |
Tuple[float, float]
|
Size of the figure. |
[5, 4]
|
fontsize |
int
|
Font size for labels and ticks. |
4
|
midpoint |
Optional[float]
|
Midpoint for diverging colormaps. |
None
|
cbar |
bool
|
Whether to show the colorbar. |
True
|
grid_linewidth |
float
|
Width of the grid lines. |
0.5
|
**kwargs |
Additional keyword arguments. |
{}
|
Returns:
Type | Description |
---|---|
Tuple[Figure, Axes, Optional[Colorbar], ndarray]
|
A tuple containing the Figure, Axes, Colorbar (if shown), and the input matrix. |
Note
This function creates a heatmap scatter plot with various customization options. The size of scatter points can be scaled based on the absolute value of the matrix elements.
Source code in flyvision/analysis/visualization/plots.py
30 31 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 |
|
flyvision.analysis.visualization.plots.hex_scatter ¶
hex_scatter(
u,
v,
values,
max_extent=None,
fig=None,
ax=None,
figsize=(1, 1),
title="",
title_y=None,
fontsize=5,
label="",
labelxy="auto",
label_color="black",
edgecolor=None,
edgewidth=0.5,
alpha=1,
fill=False,
scalarmapper=None,
norm=None,
radius=1,
origin="lower",
vmin=None,
vmax=None,
midpoint=None,
mode="default",
orientation=np.radians(30),
cmap=cm.get_cmap("seismic"),
cbar=True,
cbar_label="",
cbar_height=None,
cbar_width=None,
cbar_x_offset=0.05,
annotate=False,
annotate_coords=False,
annotate_indices=False,
frame=False,
frame_hex_width=1,
frame_color=None,
nan_linestyle="-",
text_color_hsv_threshold=0.8,
**kwargs
)
Plot a hexagonally arranged data points with coordinates u, v, and coloring color.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
u |
NDArray
|
Array of hex coordinates in u direction. |
required |
v |
NDArray
|
Array of hex coordinates in v direction. |
required |
values |
NDArray
|
Array of pixel values per point (u_i, v_i). |
required |
fill |
Union[bool, int]
|
Whether to fill the hex grid around u, v, values. |
False
|
max_extent |
Optional[int]
|
Maximum extent of the hex lattice shown. When fill=True, the hex grid is padded to the maximum extent when above the extent of u, v. |
None
|
fig |
Optional[Figure]
|
Matplotlib Figure object. |
None
|
ax |
Optional[Axes]
|
Matplotlib Axes object. |
None
|
figsize |
Tuple[float, float]
|
Size of the figure. |
(1, 1)
|
title |
str
|
Title of the plot. |
''
|
title_y |
Optional[float]
|
Y-position of the title. |
None
|
fontsize |
int
|
Font size for text elements. |
5
|
label |
str
|
Label for the plot. |
''
|
labelxy |
Union[str, Tuple[float, float]]
|
Position of the label. Either “auto” or a tuple of (x, y) coordinates. |
'auto'
|
label_color |
str
|
Color of the label. |
'black'
|
edgecolor |
Optional[str]
|
Color of the hexagon edges. |
None
|
edgewidth |
float
|
Width of the hexagon edges. |
0.5
|
alpha |
float
|
Alpha value for transparency. |
1
|
scalarmapper |
Optional[ScalarMappable]
|
ScalarMappable object for color mapping. |
None
|
norm |
Optional[Normalize]
|
Normalization for color mapping. |
None
|
radius |
float
|
Radius of the hexagons. |
1
|
origin |
Literal['lower', 'upper']
|
Origin of the plot. Either “lower” or “upper”. |
'lower'
|
vmin |
Optional[float]
|
Minimum value for color mapping. |
None
|
vmax |
Optional[float]
|
Maximum value for color mapping. |
None
|
midpoint |
Optional[float]
|
Midpoint for color mapping. |
None
|
mode |
str
|
Hex coordinate system mode. |
'default'
|
orientation |
float
|
Orientation of the hexagons in radians. |
radians(30)
|
cmap |
Colormap
|
Colormap for the plot. |
get_cmap('seismic')
|
cbar |
bool
|
Whether to show a colorbar. |
True
|
cbar_label |
str
|
Label for the colorbar. |
''
|
cbar_height |
Optional[float]
|
Height of the colorbar. |
None
|
cbar_width |
Optional[float]
|
Width of the colorbar. |
None
|
cbar_x_offset |
float
|
X-offset of the colorbar. |
0.05
|
annotate |
bool
|
Whether to annotate hexagons with values. |
False
|
annotate_coords |
bool
|
Whether to annotate hexagons with coordinates. |
False
|
annotate_indices |
bool
|
Whether to annotate hexagons with indices. |
False
|
frame |
bool
|
Whether to add a frame around the plot. |
False
|
frame_hex_width |
int
|
Width of the frame in hexagon units. |
1
|
frame_color |
Optional[Union[str, Tuple[float, float, float, float]]]
|
Color of the frame. |
None
|
nan_linestyle |
str
|
Line style for NaN values. |
'-'
|
text_color_hsv_threshold |
float
|
Threshold for text color in HSV space. |
0.8
|
**kwargs |
Additional keyword arguments. |
{}
|
Returns:
Type | Description |
---|---|
Tuple[Figure, Axes, Tuple[Optional[Line2D], ScalarMappable]]
|
A tuple containing the Figure, Axes, and a tuple of (label_text, scalarmapper). |
Source code in flyvision/analysis/visualization/plots.py
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 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 |
|
flyvision.analysis.visualization.plots.kernel ¶
kernel(
u,
v,
values,
fontsize=5,
cbar=True,
edgecolor="k",
fig=None,
ax=None,
figsize=(1, 1),
midpoint=0,
annotate=True,
alpha=0.8,
annotate_coords=False,
coord_fs=8,
cbar_height=0.3,
cbar_x_offset=-1,
**kwargs
)
Plot receptive fields with hex_scatter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
u |
NDArray
|
Array of hex coordinates in u direction. |
required |
v |
NDArray
|
Array of hex coordinates in v direction. |
required |
color |
Array of pixel values per point (u_i, v_i). |
required | |
fontsize |
int
|
Font size for text elements. |
5
|
cbar |
bool
|
Whether to show a colorbar. |
True
|
edgecolor |
str
|
Color of the hexagon edges. |
'k'
|
fig |
Optional[Figure]
|
Matplotlib Figure object. |
None
|
ax |
Optional[Axes]
|
Matplotlib Axes object. |
None
|
figsize |
Tuple[float, float]
|
Size of the figure. |
(1, 1)
|
midpoint |
float
|
Midpoint for color mapping. |
0
|
annotate |
bool
|
Whether to annotate hexagons with values. |
True
|
alpha |
float
|
Alpha value for transparency. |
0.8
|
annotate_coords |
bool
|
Whether to annotate hexagons with coordinates. |
False
|
coord_fs |
int
|
Font size for coordinate annotations. |
8
|
cbar_height |
float
|
Height of the colorbar. |
0.3
|
cbar_x_offset |
float
|
X-offset of the colorbar. |
-1
|
**kwargs |
Additional keyword arguments passed to hex_scatter. |
{}
|
Returns:
Type | Description |
---|---|
Tuple[Figure, Axes, Tuple[Optional[Line2D], ScalarMappable]]
|
A tuple containing the Figure, Axes, and a tuple of (label_text, scalarmapper). |
Raises:
Type | Description |
---|---|
SignError
|
If signs in the kernel are inconsistent. |
Note
Assigns seismic
as colormap and checks that signs are consistent.
All arguments except cmap
can be passed to hex_scatter.
Source code in flyvision/analysis/visualization/plots.py
487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 |
|
flyvision.analysis.visualization.plots.hex_cs ¶
hex_cs(
extent=5,
mode="default",
annotate_coords=True,
edgecolor="black",
**kwargs
)
Plot a hexagonal coordinate system.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
extent |
int
|
Extent of the hexagonal grid. |
5
|
mode |
Literal['default', 'flat']
|
Hex coordinate system mode. |
'default'
|
annotate_coords |
bool
|
Whether to annotate hexagons with coordinates. |
True
|
edgecolor |
str
|
Color of the hexagon edges. |
'black'
|
**kwargs |
Additional keyword arguments passed to hex_scatter. |
{}
|
Returns:
Type | Description |
---|---|
Tuple[Figure, Axes, Tuple[Optional[Line2D], ScalarMappable]]
|
A tuple containing the Figure, Axes, and a tuple of (label_text, scalarmapper). |
Source code in flyvision/analysis/visualization/plots.py
570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 |
|
flyvision.analysis.visualization.plots.quick_hex_scatter ¶
quick_hex_scatter(
values, cmap=cm.get_cmap("binary_r"), **kwargs
)
Create a hex scatter plot with implicit coordinates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
values |
NDArray
|
Array of pixel values. |
required |
cmap |
Colormap
|
Colormap for the plot. |
get_cmap('binary_r')
|
**kwargs |
Additional keyword arguments passed to hex_scatter. |
{}
|
Returns:
Type | Description |
---|---|
Tuple[Figure, Axes, Tuple[Optional[Line2D], ScalarMappable]]
|
A tuple containing the Figure, Axes, and a tuple of (label_text, scalarmapper). |
Source code in flyvision/analysis/visualization/plots.py
605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 |
|
flyvision.analysis.visualization.plots.hex_flow ¶
hex_flow(
u,
v,
flow,
fig=None,
ax=None,
figsize=(1, 1),
title="",
cmap=plt_utils.cm_uniform_2d,
max_extent=None,
cwheelradius=0.25,
mode="default",
orientation=np.radians(30),
origin="lower",
fontsize=5,
cwheel=True,
cwheelxy=(),
cwheelpos="southeast",
cwheellabelpad=-5,
annotate_r=False,
annotate_theta=False,
annotate_coords=False,
coord_fs=3,
label="",
labelxy=(0, 1),
vmin=-np.pi,
vmax=np.pi,
edgecolor=None,
**kwargs
)
Plot a hexagonal lattice with coordinates u, v, and flow.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
u |
NDArray
|
Array of hex coordinates in u direction. |
required |
v |
NDArray
|
Array of hex coordinates in v direction. |
required |
flow |
NDArray
|
Array of flow per point (u_i, v_i), shape [2, len(u)]. |
required |
fig |
Optional[Figure]
|
Matplotlib Figure object. |
None
|
ax |
Optional[Axes]
|
Matplotlib Axes object. |
None
|
figsize |
Tuple[float, float]
|
Size of the figure. |
(1, 1)
|
title |
str
|
Title of the plot. |
''
|
cmap |
Colormap
|
Colormap for the plot. |
cm_uniform_2d
|
max_extent |
Optional[int]
|
Maximum extent of the hex lattice. |
None
|
cwheelradius |
float
|
Radius of the colorwheel. |
0.25
|
mode |
Literal['default', 'flat']
|
Hex coordinate system mode. |
'default'
|
orientation |
float
|
Orientation of hexagons in radians. |
radians(30)
|
origin |
Literal['lower', 'upper']
|
Origin of the plot. |
'lower'
|
fontsize |
int
|
Font size for text elements. |
5
|
cwheel |
bool
|
Whether to show a colorwheel. |
True
|
cwheelxy |
Tuple[float, float]
|
Position of the colorwheel. |
()
|
cwheelpos |
str
|
Position of the colorwheel. |
'southeast'
|
cwheellabelpad |
float
|
Padding for colorwheel labels. |
-5
|
annotate_r |
bool
|
Whether to annotate hexagons with magnitude. |
False
|
annotate_theta |
bool
|
Whether to annotate hexagons with angle. |
False
|
annotate_coords |
bool
|
Whether to annotate hexagons with coordinates. |
False
|
coord_fs |
int
|
Font size for coordinate annotations. |
3
|
label |
str
|
Label for the plot. |
''
|
labelxy |
Tuple[float, float]
|
Position of the label. |
(0, 1)
|
vmin |
float
|
Minimum value for color mapping. |
-pi
|
vmax |
float
|
Maximum value for color mapping. |
pi
|
edgecolor |
Optional[str]
|
Color of the hexagon edges. |
None
|
**kwargs |
Additional keyword arguments. |
{}
|
Returns:
Type | Description |
---|---|
Tuple[Figure, Axes, Tuple[Optional[Line2D], ScalarMappable, Optional[Colorbar], Optional[PathCollection]]]
|
A tuple containing the Figure, Axes, and a tuple of (label_text, scalarmapper, colorbar, scatter). |
Note
Works largely like hex_scatter, but with 2d-flow instead of 1d-intensities.
Source code in flyvision/analysis/visualization/plots.py
626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 |
|
flyvision.analysis.visualization.plots.quick_hex_flow ¶
quick_hex_flow(flow, **kwargs)
Plot a flow field on a hexagonal lattice with implicit coordinates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
flow |
NDArray
|
Array of flow values. |
required |
**kwargs |
Additional keyword arguments passed to hex_flow. |
{}
|
Returns:
Type | Description |
---|---|
Tuple[Figure, Axes, Tuple[Optional[Line2D], ScalarMappable, Optional[Colorbar], Optional[PathCollection]]]
|
A tuple containing the Figure, Axes, and a tuple of (label_text, scalarmapper, colorbar, scatter). |
Source code in flyvision/analysis/visualization/plots.py
827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 |
|
flyvision.analysis.visualization.plots.flow_to_rgba ¶
flow_to_rgba(flow)
Map cartesian flow to RGBA colors.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
flow |
Union[ndarray, Tensor]
|
Flow field of shape (2, h, w). |
required |
Returns:
Type | Description |
---|---|
ndarray
|
RGBA color representation of the flow field. |
Note
The flow magnitude is mapped to the alpha channel, while the flow direction is mapped to the color using a uniform 2D colormap.
Source code in flyvision/analysis/visualization/plots.py
857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 |
|
flyvision.analysis.visualization.plots.plot_flow ¶
plot_flow(flow)
Plot cartesian flow.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
flow |
Union[ndarray, Tensor]
|
Flow field of shape (2, h, w). |
required |
Note
This function displays the flow field using matplotlib’s imshow and immediately shows the plot.
Source code in flyvision/analysis/visualization/plots.py
884 885 886 887 888 889 890 891 892 893 894 895 896 |
|
flyvision.analysis.visualization.plots.traces ¶
traces(
trace,
x=None,
contour=None,
legend=(),
smooth=None,
stim_line=None,
contour_cmap=cm.get_cmap("bone"),
color=None,
label="",
labelxy=(0, 1),
linewidth=1,
ax=None,
fig=None,
title="",
highlight_mean=False,
figsize=(7, 4),
fontsize=10,
ylim=None,
ylabel="",
xlabel="",
legend_frame_alpha=0,
contour_mode="full",
contour_y_rel=0.06,
fancy=False,
scale_pos=None,
scale_label="100ms",
null_line=False,
zorder_traces=None,
zorder_mean=None,
**kwargs
)
Create a line plot with optional contour and smoothing.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
trace |
NDArray
|
2D array (n_traces, n_points) of trace values. |
required |
x |
Optional[NDArray]
|
X-axis values. |
None
|
contour |
Optional[NDArray]
|
Array of contour values. |
None
|
legend |
Tuple[str, ...]
|
Legend for each trace. |
()
|
smooth |
Optional[float]
|
Size of smoothing window in percent of #points. |
None
|
stim_line |
Optional[NDArray]
|
Stimulus line data. |
None
|
contour_cmap |
Colormap
|
Colormap for the contour. |
get_cmap('bone')
|
color |
Optional[Union[str, List[str]]]
|
Color(s) for the traces. |
None
|
label |
str
|
Label for the plot. |
''
|
labelxy |
Tuple[float, float]
|
Position of the label. |
(0, 1)
|
linewidth |
float
|
Width of the trace lines. |
1
|
ax |
Optional[Axes]
|
Matplotlib Axes object. |
None
|
fig |
Optional[Figure]
|
Matplotlib Figure object. |
None
|
title |
str
|
Title of the plot. |
''
|
highlight_mean |
bool
|
Whether to highlight the mean trace. |
False
|
figsize |
Tuple[float, float]
|
Size of the figure. |
(7, 4)
|
fontsize |
int
|
Font size for text elements. |
10
|
ylim |
Optional[Tuple[float, float]]
|
Y-axis limits. |
None
|
ylabel |
str
|
Y-axis label. |
''
|
xlabel |
str
|
X-axis label. |
''
|
legend_frame_alpha |
float
|
Alpha value for the legend frame. |
0
|
contour_mode |
Literal['full', 'top', 'bottom']
|
Mode for contour plotting. |
'full'
|
contour_y_rel |
float
|
Relative Y position for contour in “top” or “bottom” mode. |
0.06
|
fancy |
bool
|
Whether to use fancy styling. |
False
|
scale_pos |
Optional[str]
|
Position of the scale bar. |
None
|
scale_label |
str
|
Label for the scale bar. |
'100ms'
|
null_line |
bool
|
Whether to draw a null line at y=0. |
False
|
zorder_traces |
Optional[int]
|
Z-order for traces. |
None
|
zorder_mean |
Optional[int]
|
Z-order for mean trace. |
None
|
**kwargs |
Additional keyword arguments. |
{}
|
Returns:
Type | Description |
---|---|
Tuple[Figure, Axes, NDArray, Optional[Line2D]]
|
A tuple containing the Figure, Axes, smoothed trace, and label text. |
Note
This function creates a line plot with various options for customization, including contour plotting and trace smoothing.
Source code in flyvision/analysis/visualization/plots.py
900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 |
|
flyvision.analysis.visualization.plots.grouped_traces ¶
grouped_traces(
trace_groups,
x=None,
legend=(),
color=None,
linewidth=1,
ax=None,
fig=None,
title="",
highlight_mean=False,
figsize=(7, 4),
fontsize=10,
ylim=None,
ylabel="",
xlabel="",
legend_frame_alpha=0,
**kwargs
)
Create a line plot with grouped traces.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
trace_groups |
List[ndarray]
|
List of 2D arrays, each containing trace values. |
required |
x |
Optional[ndarray]
|
X-axis values. |
None
|
legend |
Tuple[str, ...]
|
Legend for each trace group. |
()
|
color |
Optional[Union[str, List[str]]]
|
Color(s) for the trace groups. |
None
|
linewidth |
float
|
Width of the trace lines. |
1
|
ax |
Optional[Axes]
|
Matplotlib Axes object. |
None
|
fig |
Optional[Figure]
|
Matplotlib Figure object. |
None
|
title |
str
|
Title of the plot. |
''
|
highlight_mean |
bool
|
Whether to highlight the mean trace. |
False
|
figsize |
Tuple[float, float]
|
Size of the figure. |
(7, 4)
|
fontsize |
int
|
Font size for text elements. |
10
|
ylim |
Optional[Tuple[float, float]]
|
Y-axis limits. |
None
|
ylabel |
str
|
Y-axis label. |
''
|
xlabel |
str
|
X-axis label. |
''
|
legend_frame_alpha |
float
|
Alpha value for the legend frame. |
0
|
**kwargs |
Additional keyword arguments passed to traces(). |
{}
|
Returns:
Type | Description |
---|---|
Tuple[Figure, Axes]
|
A tuple containing the Figure and Axes objects. |
Source code in flyvision/analysis/visualization/plots.py
1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 |
|
flyvision.analysis.visualization.plots.get_violin_x_locations ¶
get_violin_x_locations(
n_groups, n_random_variables, violin_width
)
Calculate x-axis locations for violin plots.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_groups |
int
|
Number of groups. |
required |
n_random_variables |
int
|
Number of random variables. |
required |
violin_width |
float
|
Width of each violin plot. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
A tuple containing: |
ndarray
|
|
Tuple[ndarray, ndarray]
|
|
Source code in flyvision/analysis/visualization/plots.py
1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 |
|
flyvision.analysis.visualization.plots.violin_groups ¶
violin_groups(
values,
xticklabels=None,
pvalues=None,
display_pvalues_kwargs={},
legend=False,
legend_kwargs={},
as_bars=False,
colors=None,
cmap=mpl.colormaps["tab10"],
cstart=0,
cdist=1,
figsize=(10, 1),
title="",
ylabel=None,
ylim=None,
rotation=90,
width=0.7,
fontsize=6,
ax=None,
fig=None,
showmeans=False,
showmedians=True,
grid=False,
scatter=True,
scatter_radius=3,
scatter_edge_color=None,
scatter_edge_width=0.5,
violin_alpha=0.5,
violin_marker_lw=0.5,
violin_marker_color="k",
color_by="groups",
zorder_mean_median=5,
zorder_min_max=5,
mean_median_linewidth=0.5,
mean_median_color="k",
mean_median_bar_length=None,
**kwargs
)
Create violin plots or bar plots for grouped data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
values |
ndarray
|
Array of shape (n_random_variables, n_groups, n_samples). |
required |
xticklabels |
Optional[List[str]]
|
Labels for the x-axis ticks (random variables). |
None
|
pvalues |
Optional[ndarray]
|
Array of p-values for statistical significance. |
None
|
display_pvalues_kwargs |
dict
|
Keyword arguments for displaying p-values. |
{}
|
legend |
Union[bool, List[str]]
|
If True or a list, display a legend with group labels. |
False
|
legend_kwargs |
dict
|
Keyword arguments for the legend. |
{}
|
as_bars |
bool
|
If True, create bar plots instead of violin plots. |
False
|
colors |
Optional[List[str]]
|
List of colors for the violins or bars. |
None
|
cmap |
Colormap
|
Colormap to use when colors are not provided. |
colormaps['tab10']
|
cstart |
float
|
Starting point in the colormap. |
0
|
cdist |
float
|
Distance between colors in the colormap. |
1
|
figsize |
Tuple[float, float]
|
Size of the figure (width, height). |
(10, 1)
|
title |
str
|
Title of the plot. |
''
|
ylabel |
Optional[str]
|
Label for the y-axis. |
None
|
ylim |
Optional[Tuple[float, float]]
|
Limits for the y-axis (min, max). |
None
|
rotation |
float
|
Rotation angle for x-axis labels. |
90
|
width |
float
|
Width of the violins or bars. |
0.7
|
fontsize |
int
|
Font size for labels and ticks. |
6
|
ax |
Optional[Axes]
|
Existing Axes object to plot on. |
None
|
fig |
Optional[Figure]
|
Existing Figure object to use. |
None
|
showmeans |
bool
|
If True, show mean lines on violins. |
False
|
showmedians |
bool
|
If True, show median lines on violins. |
True
|
grid |
bool
|
If True, display a grid. |
False
|
scatter |
bool
|
If True, scatter individual data points. |
True
|
scatter_radius |
float
|
Size of scattered points. |
3
|
scatter_edge_color |
Optional[str]
|
Color of scattered point edges. |
None
|
scatter_edge_width |
float
|
Width of scattered point edges. |
0.5
|
violin_alpha |
float
|
Alpha (transparency) of violin plots. |
0.5
|
violin_marker_lw |
float
|
Line width of violin markers. |
0.5
|
violin_marker_color |
str
|
Color of violin markers. |
'k'
|
color_by |
Literal['groups', 'experiments']
|
Whether to color by “groups” or “experiments”. |
'groups'
|
zorder_mean_median |
int
|
Z-order for mean and median lines. |
5
|
zorder_min_max |
int
|
Z-order for min and max lines. |
5
|
mean_median_linewidth |
float
|
Line width for mean and median lines. |
0.5
|
mean_median_color |
str
|
Color for mean and median lines. |
'k'
|
mean_median_bar_length |
Optional[float]
|
Length of mean and median bars. |
None
|
**kwargs |
Additional keyword arguments. |
{}
|
Returns:
Type | Description |
---|---|
Figure
|
A tuple containing: |
Axes
|
|
ViolinData
|
|
Tuple[Figure, Axes, ViolinData]
|
|
Raises:
Type | Description |
---|---|
ValueError
|
If color specifications are invalid. |
Note
This function creates either violin plots or bar plots for grouped data, with options for customizing colors, scatter plots, and statistical annotations.
Source code in flyvision/analysis/visualization/plots.py
1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 |
|
flyvision.analysis.visualization.plots.plot_complex ¶
plot_complex(
z,
marker="s",
fig=None,
ax=None,
figsize=(1, 1),
fontsize=5,
)
Plot a complex number on a polar plot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
z |
complex
|
Complex number to plot. |
required |
marker |
str
|
Marker style for the point. |
's'
|
fig |
Optional[Figure]
|
Existing figure to plot on. |
None
|
ax |
Optional[Axes]
|
Existing axes to plot on. |
None
|
figsize |
Tuple[float, float]
|
Size of the figure. |
(1, 1)
|
fontsize |
int
|
Font size for text elements. |
5
|
Returns:
Type | Description |
---|---|
Tuple[Figure, Axes]
|
A tuple containing the Figure and Axes objects. |
Source code in flyvision/analysis/visualization/plots.py
1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 |
|
flyvision.analysis.visualization.plots.plot_complex_vector ¶
plot_complex_vector(
z0,
z1,
marker="s",
fig=None,
ax=None,
figsize=(1, 1),
fontsize=5,
)
Plot a vector between two complex numbers on a polar plot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
z0 |
complex
|
Starting complex number. |
required |
z1 |
complex
|
Ending complex number. |
required |
marker |
str
|
Marker style for the points. |
's'
|
fig |
Optional[Figure]
|
Existing figure to plot on. |
None
|
ax |
Optional[Axes]
|
Existing axes to plot on. |
None
|
figsize |
Tuple[float, float]
|
Size of the figure. |
(1, 1)
|
fontsize |
int
|
Font size for text elements. |
5
|
Returns:
Type | Description |
---|---|
Tuple[Figure, Axes]
|
A tuple containing the Figure and Axes objects. |
Source code in flyvision/analysis/visualization/plots.py
1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 |
|
flyvision.analysis.visualization.plots.polar ¶
polar(
theta,
r,
ax=None,
fig=None,
color="b",
linestyle="-",
marker="",
markersize=None,
label=None,
title="",
figsize=(5, 5),
fontsize=10,
xlabel="",
fontweight="normal",
anglepad=-2,
xlabelpad=-3,
linewidth=2,
ymin=None,
ymax=None,
stroke_kwargs={},
yticks_off=True,
zorder=100,
**kwargs
)
Create a polar tuning plot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
theta |
NDArray
|
Array of angles in degrees. |
required |
r |
NDArray
|
Array of radii. |
required |
ax |
Optional[Axes]
|
Matplotlib Axes object. |
None
|
fig |
Optional[Figure]
|
Matplotlib Figure object. |
None
|
color |
Union[str, List[str]]
|
Color(s) for the plot. |
'b'
|
linestyle |
str
|
Line style for the plot. |
'-'
|
marker |
str
|
Marker style for data points. |
''
|
markersize |
Optional[float]
|
Size of markers. |
None
|
label |
Optional[str]
|
Label for the plot. |
None
|
title |
str
|
Title of the plot. |
''
|
figsize |
Tuple[float, float]
|
Size of the figure. |
(5, 5)
|
fontsize |
int
|
Font size for text elements. |
10
|
xlabel |
str
|
X-axis label. |
''
|
fontweight |
Literal['normal', 'bold', 'light', 'ultralight', 'heavy', 'black', 'semibold']
|
Font weight for labels. |
'normal'
|
anglepad |
int
|
Padding for angle labels. |
-2
|
xlabelpad |
int
|
Padding for x-axis label. |
-3
|
linewidth |
float
|
Width of the plot lines. |
2
|
ymin |
Optional[float]
|
Minimum y-axis value. |
None
|
ymax |
Optional[float]
|
Maximum y-axis value. |
None
|
stroke_kwargs |
dict
|
Keyword arguments for stroke effects. |
{}
|
yticks_off |
bool
|
Whether to turn off y-axis ticks. |
True
|
zorder |
Union[int, List[int]]
|
Z-order for plot elements. |
100
|
**kwargs |
Additional keyword arguments. |
{}
|
Returns:
Type | Description |
---|---|
Tuple[Figure, Axes]
|
A tuple containing the Figure and Axes objects. |
Note
This function creates a polar plot with various customization options. It supports multiple traces and custom styling.
Source code in flyvision/analysis/visualization/plots.py
1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 |
|
flyvision.analysis.visualization.plots.multi_polar ¶
multi_polar(
theta,
r,
ax=None,
fig=None,
mean_color="b",
norm=False,
std=False,
color="b",
mean=False,
linestyle="-",
marker="",
label="",
legend=False,
title="",
figsize=(0.98, 2.38),
fontsize=5,
xlabel="",
fontweight="bold",
alpha=1,
anglepad=-6,
xlabelpad=-3,
linewidth=0.75,
ymin=None,
ymax=None,
zorder=None,
legend_kwargs=dict(fontsize=5),
rm_yticks=True,
**kwargs
)
Create a polar tuning plot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
theta |
ndarray
|
Angles in degrees. |
required |
r |
ndarray
|
Radius values. Shape (n_samples, n_values). |
required |
ax |
Optional[Axes]
|
Existing Axes object to plot on. Defaults to None. |
None
|
fig |
Optional[Figure]
|
Existing Figure object to use. Defaults to None. |
None
|
mean_color |
str
|
Color for the mean line. Defaults to “b”. |
'b'
|
norm |
bool
|
Whether to normalize the radius values. Defaults to False. |
False
|
std |
bool
|
Whether to plot standard deviation. Defaults to False. |
False
|
color |
Union[str, List[str], ndarray]
|
Color(s) for the lines. Defaults to “b”. |
'b'
|
mean |
bool
|
Whether to plot the mean. Defaults to False. |
False
|
linestyle |
str
|
Style of the lines. Defaults to “-“. |
'-'
|
marker |
str
|
Marker style for data points. Defaults to “”. |
''
|
label |
Union[str, List[str]]
|
Label(s) for the lines. Defaults to “”. |
''
|
legend |
bool
|
Whether to show a legend. Defaults to False. |
False
|
title |
str
|
Title of the plot. Defaults to “”. |
''
|
figsize |
Tuple[float, float]
|
Size of the figure. Defaults to (0.98, 2.38). |
(0.98, 2.38)
|
fontsize |
int
|
Font size for text elements. Defaults to 5. |
5
|
xlabel |
str
|
Label for the x-axis. Defaults to “”. |
''
|
fontweight |
str
|
Font weight for labels. Defaults to “bold”. |
'bold'
|
alpha |
float
|
Alpha value for line transparency. Defaults to 1. |
1
|
anglepad |
int
|
Padding for angle labels. Defaults to -6. |
-6
|
xlabelpad |
int
|
Padding for x-axis label. Defaults to -3. |
-3
|
linewidth |
float
|
Width of the lines. Defaults to 0.75. |
0.75
|
ymin |
Optional[float]
|
Minimum y-axis value. Defaults to None. |
None
|
ymax |
Optional[float]
|
Maximum y-axis value. Defaults to None. |
None
|
zorder |
Optional[Union[int, List[int], ndarray]]
|
Z-order for drawing. Defaults to None. |
None
|
legend_kwargs |
Dict[str, Any]
|
Additional keyword arguments for legend. Defaults to dict(fontsize=5). |
dict(fontsize=5)
|
rm_yticks |
bool
|
Whether to remove y-axis ticks. Defaults to True. |
True
|
**kwargs |
Any
|
Additional keyword arguments. |
{}
|
Returns:
Type | Description |
---|---|
Tuple[Figure, Axes]
|
A tuple containing the Figure and Axes objects. |
Note
This function creates a polar plot with multiple traces, optionally showing mean and standard deviation.
Source code in flyvision/analysis/visualization/plots.py
1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 |
|
flyvision.analysis.visualization.plots.loss_curves ¶
loss_curves(
losses,
smooth=0.05,
subsample=1,
mean=False,
grid=True,
colors=None,
cbar=False,
cmap=None,
norm=None,
fig=None,
ax=None,
xlabel=None,
ylabel=None,
)
Plot loss traces.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
losses |
List[ndarray]
|
List of loss arrays, each of shape (n_iters,). |
required |
smooth |
float
|
Smoothing factor for the loss curves. |
0.05
|
subsample |
int
|
Subsample factor for the loss curves. |
1
|
mean |
bool
|
Whether to plot the mean loss curve. |
False
|
grid |
bool
|
Whether to show grid lines. |
True
|
colors |
Optional[List[str]]
|
List of colors for the loss curves. |
None
|
cbar |
bool
|
Whether to add a colorbar. |
False
|
cmap |
Optional[Colormap]
|
Colormap for the loss curves. |
None
|
norm |
Optional[Normalize]
|
Normalization for the colormap. |
None
|
fig |
Optional[Figure]
|
Existing figure to plot on. |
None
|
ax |
Optional[Axes]
|
Existing axes to plot on. |
None
|
xlabel |
Optional[str]
|
Label for the x-axis. |
None
|
ylabel |
Optional[str]
|
Label for the y-axis. |
None
|
Returns:
Type | Description |
---|---|
Tuple[Figure, Axes]
|
A tuple containing the Figure and Axes objects. |
Note
This function plots loss curves for multiple models, with options for smoothing, subsampling, and various visual customizations.
Source code in flyvision/analysis/visualization/plots.py
1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 |
|
flyvision.analysis.visualization.plots.histogram ¶
histogram(
array,
bins=None,
fill=False,
histtype="step",
figsize=(1, 1),
fontsize=5,
fig=None,
ax=None,
xlabel=None,
ylabel=None,
)
Create a histogram plot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array |
ndarray
|
Input data to plot. |
required |
bins |
Optional[Union[int, Sequence, str]]
|
Number of bins or bin edges. Defaults to len(array). |
None
|
fill |
bool
|
Whether to fill the bars. Defaults to False. |
False
|
histtype |
Literal['bar', 'barstacked', 'step', 'stepfilled']
|
Type of histogram to plot. Defaults to “step”. |
'step'
|
figsize |
Tuple[float, float]
|
Size of the figure. Defaults to (1, 1). |
(1, 1)
|
fontsize |
int
|
Font size for labels. Defaults to 5. |
5
|
fig |
Optional[Figure]
|
Existing figure to plot on. Defaults to None. |
None
|
ax |
Optional[Axes]
|
Existing axes to plot on. Defaults to None. |
None
|
xlabel |
Optional[str]
|
Label for x-axis. Defaults to None. |
None
|
ylabel |
Optional[str]
|
Label for y-axis. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
Tuple[Figure, Axes]
|
A tuple containing the Figure and Axes objects. |
Source code in flyvision/analysis/visualization/plots.py
1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 |
|
flyvision.analysis.visualization.plots.violins ¶
violins(
variable_names,
variable_values,
ylabel=None,
title=None,
max_per_ax=20,
colors=None,
cmap=plt.cm.viridis_r,
fontsize=5,
violin_width=0.7,
legend=None,
scatter_extent=[-0.35, 0.35],
figwidth=10,
fig=None,
axes=None,
ylabel_offset=0.2,
**kwargs
)
Create violin plots for multiple variables across groups.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
variable_names |
List[str]
|
Names of the variables to plot. |
required |
variable_values |
ndarray
|
Array of values for each variable and group. |
required |
ylabel |
Optional[str]
|
Label for the y-axis. |
None
|
title |
Optional[str]
|
Title of the plot. |
None
|
max_per_ax |
Optional[int]
|
Maximum number of variables per axis. |
20
|
colors |
Optional[Union[str, List[str]]]
|
Colors for the violin plots. |
None
|
cmap |
cm
|
Colormap to use if colors are not specified. |
viridis_r
|
fontsize |
int
|
Font size for labels and ticks. |
5
|
violin_width |
float
|
Width of each violin plot. |
0.7
|
legend |
Optional[Union[str, List[str]]]
|
Legend labels for groups. |
None
|
scatter_extent |
List[float]
|
Extent of scatter points on violins. |
[-0.35, 0.35]
|
figwidth |
float
|
Width of the figure. |
10
|
fig |
Optional[Figure]
|
Existing figure to plot on. |
None
|
axes |
Optional[List[Axes]]
|
Existing axes to plot on. |
None
|
ylabel_offset |
float
|
Offset for y-axis label. |
0.2
|
**kwargs |
Any
|
Additional keyword arguments for violin_groups function. |
{}
|
Returns:
Type | Description |
---|---|
Tuple[Figure, List[Axes]]
|
A tuple containing the Figure and list of Axes objects. |
Note
This function creates violin plots for multiple variables, potentially across multiple groups, with optional scatter points on each violin.
Source code in flyvision/analysis/visualization/plots.py
2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 |
|
flyvision.analysis.visualization.plots.plot_strf ¶
plot_strf(
time,
rf,
hlines=True,
vlines=True,
time_axis=True,
fontsize=6,
fig=None,
axes=None,
figsize=[5, 1],
wspace=0,
y_offset_time_axis=0,
)
Plot a Spatio-Temporal Receptive Field (STRF).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
time |
ndarray
|
Array of time points. |
required |
rf |
ndarray
|
Receptive field array. |
required |
hlines |
bool
|
Whether to draw horizontal lines. Defaults to True. |
True
|
vlines |
bool
|
Whether to draw vertical lines. Defaults to True. |
True
|
time_axis |
bool
|
Whether to add a time axis. Defaults to True. |
True
|
fontsize |
int
|
Font size for labels and ticks. |
6
|
fig |
Optional[Figure]
|
Existing figure to plot on. |
None
|
axes |
Optional[ndarray]
|
Existing axes to plot on. |
None
|
figsize |
List[float]
|
Size of the figure as [width, height]. |
[5, 1]
|
wspace |
float
|
Width space between subplots. |
0
|
y_offset_time_axis |
float
|
Vertical offset for the time axis. |
0
|
Returns:
Type | Description |
---|---|
Tuple[Figure, ndarray]
|
A tuple containing the Figure and Axes objects. |
Note
This function creates a series of hexagonal plots representing the STRF at different time points.
Source code in flyvision/analysis/visualization/plots.py
2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 |
|
Classes¶
flyvision.analysis.visualization.plots.ViolinData
dataclass
¶
Container for violin plot data.
Attributes:
Name | Type | Description |
---|---|---|
data |
ndarray
|
np.ndarray The data used for creating violin plots. |
locations |
ndarray
|
np.ndarray The x-axis locations of the violin plots. |
colors |
ndarray
|
np.ndarray The colors used for the violin plots. |
Source code in flyvision/analysis/visualization/plots.py
1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 |
|
flyvision.analysis.visualization.plt_utils¶
Functions¶
flyvision.analysis.visualization.plt_utils.check_markers ¶
check_markers(N)
Check if the number of clusters is larger than the number of markers.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
N |
int
|
Number of clusters. |
required |
Returns:
Type | Description |
---|---|
List[str]
|
List of markers. |
Source code in flyvision/analysis/visualization/plt_utils.py
21 22 23 24 25 26 27 28 29 30 31 32 33 |
|
flyvision.analysis.visualization.plt_utils.get_marker ¶
get_marker(n)
Get marker for n.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n |
int
|
Index of the marker. |
required |
Returns:
Type | Description |
---|---|
str
|
Marker string. |
Source code in flyvision/analysis/visualization/plt_utils.py
36 37 38 39 40 41 42 43 44 45 46 |
|
flyvision.analysis.visualization.plt_utils.init_plot ¶
init_plot(
figsize=[1, 1],
title="",
fontsize=5,
ax=None,
fig=None,
projection=None,
set_axis_off=False,
transparent=False,
face_alpha=0,
position=None,
title_pos="center",
title_y=None,
**kwargs
)
Creates fig and axis object with certain default settings.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
figsize |
List[float]
|
Figure size. |
[1, 1]
|
title |
str
|
Title of the plot. |
''
|
fontsize |
int
|
Font size for title and labels. |
5
|
ax |
Axes
|
Existing axis object. |
None
|
fig |
Figure
|
Existing figure object. |
None
|
projection |
str
|
Projection type (e.g., ‘polar’). |
None
|
set_axis_off |
bool
|
Whether to turn off axis. |
False
|
transparent |
bool
|
Whether to make the axis transparent. |
False
|
face_alpha |
float
|
Alpha value for the face color. |
0
|
position |
List[float]
|
Position for newly created axis. |
None
|
title_pos |
Literal['center', 'left', 'right']
|
Position of the title. |
'center'
|
title_y |
float
|
Y-coordinate of the title. |
None
|
Returns:
Type | Description |
---|---|
Tuple[Figure, Axes]
|
Tuple containing the figure and axis objects. |
Source code in flyvision/analysis/visualization/plt_utils.py
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 |
|
flyvision.analysis.visualization.plt_utils.truncate_colormap ¶
truncate_colormap(cmap, minval=0.0, maxval=1.0, n=100)
Truncate colormap.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cmap |
Colormap
|
Original colormap. |
required |
minval |
float
|
Minimum value for truncation. |
0.0
|
maxval |
float
|
Maximum value for truncation. |
1.0
|
n |
int
|
Number of colors in the new colormap. |
100
|
Returns:
Type | Description |
---|---|
LinearSegmentedColormap
|
Truncated colormap. |
Source code in flyvision/analysis/visualization/plt_utils.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
|
flyvision.analysis.visualization.plt_utils.rm_spines ¶
rm_spines(
ax,
spines=("top", "right", "bottom", "left"),
visible=False,
rm_xticks=True,
rm_yticks=True,
)
Removes spines and ticks from axis.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ax |
Axes
|
Matplotlib axis object. |
required |
spines |
Tuple[str, ...]
|
Tuple of spines to remove. |
('top', 'right', 'bottom', 'left')
|
visible |
bool
|
Whether to make spines visible. |
False
|
rm_xticks |
bool
|
Whether to remove x-ticks. |
True
|
rm_yticks |
bool
|
Whether to remove y-ticks. |
True
|
Returns:
Type | Description |
---|---|
Axes
|
Modified axis object. |
Source code in flyvision/analysis/visualization/plt_utils.py
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 |
|
flyvision.analysis.visualization.plt_utils.get_ax_positions ¶
get_ax_positions(axes)
Returns the positions of the axes in the figure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
axes |
Iterable[Axes]
|
Single ax or iterable of axes. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
Tuple containing arrays of left, bottom, right, and top positions, |
ndarray
|
and arrays of centers, widths, and heights. |
Source code in flyvision/analysis/visualization/plt_utils.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
|
flyvision.analysis.visualization.plt_utils.is_hex ¶
is_hex(color)
Checks if color is hex.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
color |
str
|
Color string. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if color is hex, False otherwise. |
Source code in flyvision/analysis/visualization/plt_utils.py
177 178 179 180 181 182 183 184 185 186 187 |
|
flyvision.analysis.visualization.plt_utils.is_integer_rgb ¶
is_integer_rgb(color)
Checks if color is integer RGB.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
color |
Iterable[int]
|
Color tuple or list. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if color is integer RGB, False otherwise. |
Source code in flyvision/analysis/visualization/plt_utils.py
190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
|
flyvision.analysis.visualization.plt_utils.get_alpha_colormap ¶
get_alpha_colormap(saturated_color, number_of_shades)
Create a colormap from a color and a number of shades.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
saturated_color |
str
|
Saturated color string. |
required |
number_of_shades |
int
|
Number of shades in the colormap. |
required |
Returns:
Type | Description |
---|---|
ListedColormap
|
ListedColormap object. |
Source code in flyvision/analysis/visualization/plt_utils.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
|
flyvision.analysis.visualization.plt_utils.polar_to_cmap ¶
polar_to_cmap(
r,
theta,
invert=True,
cmap=plt.cm.twilight_shifted,
norm=None,
sm=None,
)
Maps angle to rgb and amplitude to alpha and returns the resulting array.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
r |
ndarray
|
Amplitude array. |
required |
theta |
ndarray
|
Angle array. |
required |
invert |
bool
|
Whether to invert the colormap. |
True
|
cmap |
Colormap
|
Colormap. |
twilight_shifted
|
norm |
Normalize
|
Normalization object. |
None
|
sm |
ScalarMappable
|
ScalarMappable object. |
None
|
Returns:
Type | Description |
---|---|
ndarray
|
RGBA array. |
Source code in flyvision/analysis/visualization/plt_utils.py
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 |
|
flyvision.analysis.visualization.plt_utils.add_colorwheel_2d ¶
add_colorwheel_2d(
fig,
axes=None,
pos="southeast",
radius=0.25,
x_offset=0,
y_offset=0,
sm=None,
cmap="cm_uniform_2d",
norm=None,
fontsize=6,
N=512,
labelpad=0,
invert=False,
mode="2d",
ticks=[0, 60, 120],
)
Adds a colorwheel to a figure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fig |
Figure
|
Matplotlib figure object. |
required |
axes |
Iterable[Axes]
|
Iterable of axes to which the colorwheel will be added. |
None
|
pos |
Literal['southeast', 'east', 'northeast', 'north', 'northwest', 'west', 'southwest', 'south', 'origin']
|
Position of the colorwheel. |
'southeast'
|
radius |
float
|
Radius of the colorwheel in percentage of the ax radius. |
0.25
|
x_offset |
float
|
X-offset of the colorwheel in percentage of the cbar diameter. |
0
|
y_offset |
float
|
Y-offset of the colorwheel in percentage of the cbar diameter. |
0
|
sm |
ScalarMappable
|
ScalarMappable object. |
None
|
cmap |
str
|
Colormap name. |
'cm_uniform_2d'
|
norm |
Normalize
|
Normalization object. |
None
|
fontsize |
int
|
Font size for tick labels. |
6
|
N |
int
|
Number of samples for the colorwheel. |
512
|
labelpad |
float
|
Padding for tick labels. |
0
|
invert |
bool
|
Whether to invert the colormap. |
False
|
mode |
Literal['1d', '2d']
|
Mode of the colorwheel (“1d” or “2d”). |
'2d'
|
ticks |
List[int]
|
Tick positions in degrees. |
[0, 60, 120]
|
Returns:
Type | Description |
---|---|
Tuple[Axes, Axes]
|
Tuple containing the colorwheel axis and the annotation axis. |
Source code in flyvision/analysis/visualization/plt_utils.py
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 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 |
|
flyvision.analysis.visualization.plt_utils.add_cluster_marker ¶
add_cluster_marker(
fig,
ax,
marker="o",
marker_size=15,
color="#4F73AE",
x_offset=0,
y_offset=0,
)
Adds a cluster marker to a figure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fig |
Figure
|
Matplotlib figure object. |
required |
ax |
Axes
|
Matplotlib axis object. |
required |
marker |
str
|
Marker style. |
'o'
|
marker_size |
int
|
Marker size. |
15
|
color |
str
|
Marker color. |
'#4F73AE'
|
x_offset |
float
|
X-offset of the marker in percentage of the ax width. |
0
|
y_offset |
float
|
Y-offset of the marker in percentage of the ax height. |
0
|
Source code in flyvision/analysis/visualization/plt_utils.py
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 |
|
flyvision.analysis.visualization.plt_utils.derive_position_for_supplementary_ax ¶
derive_position_for_supplementary_ax(
fig,
pos="right",
width=0.04,
height=0.5,
x_offset=0,
y_offset=0,
axes=None,
)
Returns a position for a supplementary ax.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fig |
Figure
|
Matplotlib figure object. |
required |
pos |
Literal['right', 'left', 'top', 'bottom']
|
Position of the supplementary ax relative to the main axes. |
'right'
|
width |
float
|
Width of the supplementary ax in percentage of the main ax width. |
0.04
|
height |
float
|
Height of the supplementary ax in percentage of the main ax height. |
0.5
|
x_offset |
float
|
X-offset of the supplementary ax in percentage of the main ax width. |
0
|
y_offset |
float
|
Y-offset of the supplementary ax in percentage of the main ax height. |
0
|
axes |
Iterable[Axes]
|
Iterable of axes to which the supplementary ax will be added. |
None
|
Returns:
Type | Description |
---|---|
List[float]
|
List containing the left, bottom, width, and height of the supplementary ax. |
Source code in flyvision/analysis/visualization/plt_utils.py
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 |
|
flyvision.analysis.visualization.plt_utils.derive_position_for_supplementary_ax_hex ¶
derive_position_for_supplementary_ax_hex(
fig,
axes=None,
pos="southwest",
radius=0.25,
x_offset=0,
y_offset=0,
)
Returns a position for a supplementary ax.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fig |
Figure
|
Matplotlib figure object. |
required |
axes |
Iterable[Axes]
|
Iterable of axes to which the supplementary ax will be added. |
None
|
pos |
Literal['southeast', 'east', 'northeast', 'north', 'northwest', 'west', 'southwest', 'south', 'origin']
|
Position of the supplementary ax relative to the main axes. |
'southwest'
|
radius |
float
|
Radius of the supplementary ax in percentage of the main ax radius. |
0.25
|
x_offset |
float
|
X-offset of the supplementary ax in percentage of the main ax width. |
0
|
y_offset |
float
|
Y-offset of the supplementary ax in percentage of the main ax height. |
0
|
Returns:
Type | Description |
---|---|
List[float]
|
List containing the left, bottom, width, and height of the supplementary ax. |
Source code in flyvision/analysis/visualization/plt_utils.py
477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 |
|
flyvision.analysis.visualization.plt_utils.add_colorbar_to_fig ¶
add_colorbar_to_fig(
fig,
axes=None,
pos="right",
width=0.04,
height=0.5,
x_offset=0,
y_offset=0,
cmap=cm.get_cmap("binary"),
fontsize=10,
tick_length=1.5,
tick_width=0.75,
rm_outline=True,
ticks=None,
norm=None,
label="",
plain=False,
use_math_text=False,
scilimits=None,
style="",
alpha=1,
n_ticks=9,
discrete=False,
n_discrete=None,
discrete_labels=None,
n_decimals=2,
)
Adds a colorbar to a figure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fig |
Figure
|
Matplotlib figure object. |
required |
axes |
Iterable[Axes]
|
Iterable of axes to which the colorbar will be added. |
None
|
pos |
Literal['right', 'left', 'top', 'bottom']
|
Position of the colorbar. |
'right'
|
width |
float
|
Width of the colorbar in percentage of the ax width. |
0.04
|
height |
float
|
Height of the colorbar in percentage of the ax height. |
0.5
|
x_offset |
float
|
X-offset of the colorbar in percentage of the ax width. |
0
|
y_offset |
float
|
Y-offset of the colorbar in percentage of the ax height. |
0
|
cmap |
Colormap
|
Colormap. |
get_cmap('binary')
|
fontsize |
int
|
Font size for tick labels. |
10
|
tick_length |
float
|
Length of the tick marks. |
1.5
|
tick_width |
float
|
Width of the tick marks. |
0.75
|
rm_outline |
bool
|
Whether to remove the outline of the colorbar. |
True
|
ticks |
Iterable[float]
|
Tick positions. |
None
|
norm |
Normalize
|
Normalization object. |
None
|
label |
str
|
Colorbar label. |
''
|
plain |
bool
|
Whether to remove tick labels. |
False
|
use_math_text |
bool
|
Whether to use math text for tick labels. |
False
|
scilimits |
Tuple[float, float]
|
Limits for scientific notation. |
None
|
style |
str
|
Style for scientific notation. |
''
|
alpha |
float
|
Alpha value for the colorbar. |
1
|
n_ticks |
int
|
Number of ticks for TwoSlopeNorm. |
9
|
discrete |
bool
|
Whether to use discrete colors. |
False
|
n_discrete |
int
|
Number of discrete colors. |
None
|
discrete_labels |
Iterable[str]
|
Labels for discrete colors. |
None
|
n_decimals |
int
|
Number of decimal places for tick labels. |
2
|
Returns:
Type | Description |
---|---|
Colorbar
|
Matplotlib colorbar object. |
Source code in flyvision/analysis/visualization/plt_utils.py
590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 |
|
flyvision.analysis.visualization.plt_utils.get_norm ¶
get_norm(
norm=None,
vmin=None,
vmax=None,
midpoint=None,
log=None,
symlog=None,
)
Returns a normalization object for color normalization.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
norm |
Normalize
|
A class which, when called, can normalize data into an interval [vmin, vmax]. |
None
|
vmin |
float
|
Minimum value for normalization. |
None
|
vmax |
float
|
Maximum value for normalization. |
None
|
midpoint |
float
|
Midpoint value so that data is normalized around it. |
None
|
log |
bool
|
Whether to normalize on a log-scale. |
None
|
symlog |
float
|
Normalizes to symlog with linear range around the range (-symlog, symlog). |
None
|
Returns:
Type | Description |
---|---|
Normalize
|
Normalization object. |
Source code in flyvision/analysis/visualization/plt_utils.py
731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 |
|
flyvision.analysis.visualization.plt_utils.get_scalarmapper ¶
get_scalarmapper(
scalarmapper=None,
cmap=None,
norm=None,
vmin=None,
vmax=None,
midpoint=None,
log=None,
symlog=None,
)
Returns scalarmappable with norm from get_norm
and cmap.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scalarmapper |
ScalarMappable
|
Scalarmappable for data to RGBA mapping. |
None
|
cmap |
Colormap
|
Colormap. |
None
|
norm |
Normalize
|
Normalization object. |
None
|
vmin |
float
|
Minimum value for normalization. |
None
|
vmax |
float
|
Maximum value for normalization. |
None
|
midpoint |
float
|
Midpoint value for normalization. |
None
|
log |
bool
|
Whether to normalize on a log-scale. |
None
|
symlog |
float
|
Normalizes to symlog with linear range around the range (-symlog, symlog). |
None
|
Returns:
Type | Description |
---|---|
Tuple[ScalarMappable, Normalize]
|
Tuple containing the scalarmappable and the normalization object. |
Source code in flyvision/analysis/visualization/plt_utils.py
778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 |
|
flyvision.analysis.visualization.plt_utils.get_lims ¶
get_lims(z, offset, min=None, max=None)
Get scalar bounds of Ndim-array-like structure with relative offset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
z |
Union[ndarray, Iterable[ndarray]]
|
Ndim-array-like structure. |
required |
offset |
float
|
Relative offset for the bounds. |
required |
min |
float
|
Minimum value for the bounds. |
None
|
max |
float
|
Maximum value for the bounds. |
None
|
Returns:
Type | Description |
---|---|
Tuple[float, float]
|
Tuple containing the minimum and maximum values. |
Source code in flyvision/analysis/visualization/plt_utils.py
818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 |
|
flyvision.analysis.visualization.plt_utils.avg_pool ¶
avg_pool(trace, N)
Smoothes (multiple) traces over the second dimension using the GPU.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
trace |
ndarray
|
Array of shape (N, t). |
required |
N |
int
|
Window size for averaging. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
Smoothed trace array. |
Source code in flyvision/analysis/visualization/plt_utils.py
862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 |
|
flyvision.analysis.visualization.plt_utils.width_n_height ¶
width_n_height(
N, aspect_ratio, max_width=None, max_height=None
)
Integer width and height for a grid of N plots with aspect ratio.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
N |
int
|
Number of plots. |
required |
aspect_ratio |
float
|
Aspect ratio of the grid. |
required |
max_width |
int
|
Maximum width of the grid. |
None
|
max_height |
int
|
Maximum height of the grid. |
None
|
Returns:
Type | Description |
---|---|
Tuple[int, int]
|
Tuple containing the width and height of the grid. |
Source code in flyvision/analysis/visualization/plt_utils.py
882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 |
|
flyvision.analysis.visualization.plt_utils.get_axis_grid ¶
get_axis_grid(
alist=None,
gridwidth=None,
gridheight=None,
max_width=None,
max_height=None,
fig=None,
ax=None,
axes=None,
aspect_ratio=1,
figsize=None,
scale=3,
projection=None,
as_matrix=False,
fontsize=5,
wspace=0.1,
hspace=0.3,
alpha=1,
sharex=None,
sharey=None,
unmask_n=None,
)
Create axis grid for a list of elements or integer width and height.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
alist |
Iterable
|
List of elements to create grid for. |
None
|
gridwidth |
int
|
Width of grid. |
None
|
gridheight |
int
|
Height of grid. |
None
|
max_width |
int
|
Maximum width of grid. |
None
|
max_height |
int
|
Maximum height of grid. |
None
|
fig |
Figure
|
Existing figure to use. |
None
|
ax |
Axes
|
Existing axis to use. This ax will be divided into a grid of axes with the same size as the grid. |
None
|
axes |
Iterable[Axes]
|
Existing axes to use. |
None
|
aspect_ratio |
float
|
Aspect ratio of grid. |
1
|
figsize |
List[float]
|
Figure size. |
None
|
scale |
Union[int, Iterable[int]]
|
Scales figure size by this factor(s) times the grid width and height. |
3
|
projection |
Union[str, Iterable[str]]
|
Projection of axes. |
None
|
as_matrix |
bool
|
Return axes as matrix. |
False
|
fontsize |
int
|
Fontsize of axes. |
5
|
wspace |
float
|
Width space between axes. |
0.1
|
hspace |
float
|
Height space between axes. |
0.3
|
alpha |
float
|
Alpha of axes. |
1
|
sharex |
Axes
|
Share x axis. Only effective if a new grid of axes is created. |
None
|
sharey |
Axes
|
Share y axis. Only effective if a new grid of axes is created. |
None
|
unmask_n |
int
|
Number of elements to unmask. If None, all elements are unmasked. If provided elements at indices >= unmask_n are padded with nans. |
None
|
Returns:
Type | Description |
---|---|
Tuple[Figure, Union[List[Axes], ndarray], Tuple[int, int]]
|
Tuple containing the figure, axes, and the grid width and height. |
Source code in flyvision/analysis/visualization/plt_utils.py
921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 |
|
flyvision.analysis.visualization.plt_utils.figure ¶
figure(
figsize,
hspace=0.3,
wspace=0.1,
left=0.125,
right=0.9,
top=0.9,
bottom=0.1,
frameon=None,
)
Create a figure with the given size and spacing.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
figsize |
List[float]
|
Figure size. |
required |
hspace |
float
|
Height space between subplots. |
0.3
|
wspace |
float
|
Width space between subplots. |
0.1
|
left |
float
|
Left margin. |
0.125
|
right |
float
|
Right margin. |
0.9
|
top |
float
|
Top margin. |
0.9
|
bottom |
float
|
Bottom margin. |
0.1
|
frameon |
bool
|
Whether to draw the figure frame. |
None
|
Returns:
Type | Description |
---|---|
Figure
|
Matplotlib figure object. |
Source code in flyvision/analysis/visualization/plt_utils.py
1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 |
|
flyvision.analysis.visualization.plt_utils.subplot ¶
subplot(
title="",
grid=(1, 1),
location=(0, 0),
colspan=1,
rowspan=1,
projection=None,
sharex=None,
sharey=None,
xlabel="",
ylabel="",
face_alpha=1.0,
fontisze=5,
title_pos="center",
position=None,
**kwargs
)
Create a subplot using subplot2grid with some extra options.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
title |
str
|
Title of the subplot. |
''
|
grid |
Tuple[int, int]
|
Grid shape. |
(1, 1)
|
location |
Tuple[int, int]
|
Location of the subplot in the grid. |
(0, 0)
|
colspan |
int
|
Number of columns the subplot spans. |
1
|
rowspan |
int
|
Number of rows the subplot spans. |
1
|
projection |
str
|
Projection type (e.g., ‘polar’). |
None
|
sharex |
Axes
|
Axis to share x-axis with. |
None
|
sharey |
Axes
|
Axis to share y-axis with. |
None
|
xlabel |
str
|
X-axis label. |
''
|
ylabel |
str
|
Y-axis label. |
''
|
face_alpha |
float
|
Alpha value for the face color. |
1.0
|
fontisze |
int
|
Font size for title and labels. |
5
|
title_pos |
Literal['center', 'left', 'right']
|
Position of the title. |
'center'
|
position |
List[float]
|
Position for the subplot. |
None
|
Returns:
Type | Description |
---|---|
Axes
|
Matplotlib axis object. |
Source code in flyvision/analysis/visualization/plt_utils.py
1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 |
|
flyvision.analysis.visualization.plt_utils.divide_axis_to_grid ¶
divide_axis_to_grid(
ax,
matrix=((0, 1, 2), (3, 3, 3)),
wspace=0.1,
hspace=0.1,
projection=None,
)
Divides an existing axis inside a figure to a grid specified by unique elements in a matrix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ax |
Axes
|
Existing Axes object. |
required |
matrix |
ndarray
|
Grid matrix, where each unique element specifies a new axis. |
((0, 1, 2), (3, 3, 3))
|
wspace |
float
|
Horizontal space between new axes. |
0.1
|
hspace |
float
|
Vertical space between new axes. |
0.1
|
projection |
str
|
Projection of new axes. |
None
|
Returns:
Type | Description |
---|---|
Dict[Any, Axes]
|
Dictionary of new axes, where keys are unique elements in the matrix. |
Example
fig = plt.figure()
ax = plt.subplot()
plt.tight_layout()
divide_axis_to_grid(ax, matrix=[[0, 1, 1, 1, 2, 2, 2],
[3, 4, 5, 6, 2, 2, 2],
[3, 7, 7, 7, 2, 2, 2],
[3, 8, 8, 12, 2, 2, 2],
[3, 10, 11, 12, 2, 2, 2]],
wspace=0.1, hspace=0.1)
Source code in flyvision/analysis/visualization/plt_utils.py
1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 |
|
flyvision.analysis.visualization.plt_utils.divide_figure_to_grid ¶
divide_figure_to_grid(
matrix=[
[0, 1, 1, 1, 2, 2, 2],
[3, 4, 5, 6, 2, 2, 2],
[3, 7, 7, 7, 2, 2, 2],
[3, 8, 8, 12, 2, 2, 2],
[3, 10, 11, 12, 2, 2, 2],
],
as_matrix=False,
alpha=0,
constrained_layout=False,
fig=None,
figsize=[10, 10],
projection=None,
wspace=0.1,
hspace=0.3,
no_spines=False,
keep_nan_axes=False,
fontsize=5,
reshape_order="F",
)
Creates a figure grid specified by the arrangement of unique elements in a matrix.
Info
matplotlib
now also has matplotlib.pyplot.subplot_mosaic
which does the
same thing and should be used instead.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
matrix |
List[List[int]]
|
Grid layout specification. |
[[0, 1, 1, 1, 2, 2, 2], [3, 4, 5, 6, 2, 2, 2], [3, 7, 7, 7, 2, 2, 2], [3, 8, 8, 12, 2, 2, 2], [3, 10, 11, 12, 2, 2, 2]]
|
as_matrix |
bool
|
If True, return axes as a numpy array. |
False
|
alpha |
float
|
Alpha value for axis patches. |
0
|
constrained_layout |
bool
|
Use constrained layout for the figure. |
False
|
fig |
Optional[Figure]
|
Existing figure to use. If None, a new figure is created. |
None
|
figsize |
List[float]
|
Figure size in inches. |
[10, 10]
|
projection |
Optional[Union[str, List[str]]]
|
Projection type for the axes. |
None
|
wspace |
float
|
Width space between subplots. |
0.1
|
hspace |
float
|
Height space between subplots. |
0.3
|
no_spines |
bool
|
If True, remove spines from all axes. |
False
|
keep_nan_axes |
bool
|
If True, keep axes for NaN values in the matrix. |
False
|
fontsize |
int
|
Font size for tick labels. |
5
|
reshape_order |
Literal['C', 'F', 'A', 'K']
|
Order to use when reshaping the axes array. |
'F'
|
Returns:
Type | Description |
---|---|
Tuple[Figure, Union[Dict[int, Axes], ndarray]]
|
A tuple containing the figure and a dictionary or numpy array of axes. |
Source code in flyvision/analysis/visualization/plt_utils.py
1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 |
|
flyvision.analysis.visualization.plt_utils.scale ¶
scale(x, y, wpad=0.1, hpad=0.1, wspace=0, hspace=0)
Scale x and y coordinates to fit within a specified padding and spacing.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
ndarray
|
Array of x-coordinates. |
required |
y |
ndarray
|
Array of y-coordinates. |
required |
wpad |
float
|
Width padding. |
0.1
|
hpad |
float
|
Height padding. |
0.1
|
wspace |
float
|
Width space between elements. |
0
|
hspace |
float
|
Height space between elements. |
0
|
Returns:
Type | Description |
---|---|
Tuple[ndarray, ndarray, float, float]
|
A tuple containing scaled x, y coordinates, width, and height. |
Source code in flyvision/analysis/visualization/plt_utils.py
1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 |
|
flyvision.analysis.visualization.plt_utils.ax_scatter ¶
ax_scatter(
x,
y,
fig=None,
figsize=[7, 7],
hspace=0,
wspace=0,
hpad=0.1,
wpad=0.1,
alpha=0,
zorder=10,
projection=None,
labels=None,
)
Creates scattered axes in a given or new figure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
ndarray
|
Array of x-coordinates. |
required |
y |
ndarray
|
Array of y-coordinates. |
required |
fig |
Optional[Figure]
|
Existing figure to use. If None, a new figure is created. |
None
|
figsize |
List[float]
|
Figure size in inches. |
[7, 7]
|
hspace |
float
|
Height space between subplots. |
0
|
wspace |
float
|
Width space between subplots. |
0
|
hpad |
float
|
Height padding. |
0.1
|
wpad |
float
|
Width padding. |
0.1
|
alpha |
float
|
Alpha value for axis patches. |
0
|
zorder |
int
|
Z-order for axis patches. |
10
|
projection |
Optional[str]
|
Projection type for the axes. |
None
|
labels |
Optional[List[str]]
|
List of labels for each axis. |
None
|
Returns:
Type | Description |
---|---|
Tuple[Figure, List[Axes], List[List[float]]]
|
A tuple containing the figure, a list of axes, and a list of center coordinates. |
Source code in flyvision/analysis/visualization/plt_utils.py
1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 |
|
flyvision.analysis.visualization.plt_utils.color_labels ¶
color_labels(labels, color, ax)
Source code in flyvision/analysis/visualization/plt_utils.py
1426 1427 1428 |
|
flyvision.analysis.visualization.plt_utils.color_label ¶
color_label(label, color, ax)
Color a specific label in the given axes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
label |
str
|
The label text to color. |
required |
color |
Union[str, Tuple[float, float, float]]
|
The color to apply to the label. |
required |
ax |
Axes
|
The matplotlib axes object. |
required |
Source code in flyvision/analysis/visualization/plt_utils.py
1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 |
|
flyvision.analysis.visualization.plt_utils.boldify_labels ¶
boldify_labels(labels, ax)
Make specific labels bold in the given axes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
labels |
List[str]
|
List of label texts to make bold. |
required |
ax |
Axes
|
The matplotlib axes object. |
required |
Source code in flyvision/analysis/visualization/plt_utils.py
1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 |
|
flyvision.analysis.visualization.plt_utils.scatter_on_violins_or_bars ¶
scatter_on_violins_or_bars(
data,
ax,
xticks=None,
indices=None,
s=5,
zorder=100,
facecolor="none",
edgecolor="k",
linewidth=0.5,
alpha=0.35,
uniform=[-0.35, 0.35],
seed=42,
marker="o",
**kwargs
)
Scatter data points on violin or bar plots.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
ndarray
|
Array of shape (n_samples, n_random_variables). |
required |
ax |
Axes
|
Matplotlib axes object to plot on. |
required |
xticks |
Optional[ndarray]
|
X-axis tick positions. |
None
|
indices |
Optional[ndarray]
|
Selection along sample dimension. |
None
|
s |
float
|
Marker size. |
5
|
zorder |
int
|
Z-order for plotting. |
100
|
facecolor |
Union[str, Tuple[float, float, float], List[Union[str, Tuple[float, float, float]]]]
|
Color(s) for marker face. |
'none'
|
edgecolor |
Union[str, Tuple[float, float, float], List[Union[str, Tuple[float, float, float]]]]
|
Color(s) for marker edge. |
'k'
|
linewidth |
float
|
Width of marker edge. |
0.5
|
alpha |
float
|
Transparency of markers. |
0.35
|
uniform |
List[float]
|
Range for uniform distribution of x-positions. |
[-0.35, 0.35]
|
seed |
int
|
Random seed for reproducibility. |
42
|
marker |
str
|
Marker style. |
'o'
|
**kwargs |
Additional keyword arguments for plt.scatter. |
{}
|
Returns:
Type | Description |
---|---|
None
|
None |
Source code in flyvision/analysis/visualization/plt_utils.py
1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 |
|
flyvision.analysis.visualization.plt_utils.set_spine_tick_params ¶
set_spine_tick_params(
ax,
spinewidth=0.25,
tickwidth=0.25,
ticklength=3,
ticklabelpad=2,
spines=("top", "right", "bottom", "left"),
)
Set spine and tick widths and lengths.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ax |
Axes
|
Matplotlib axes object. |
required |
spinewidth |
float
|
Width of spines. |
0.25
|
tickwidth |
float
|
Width of ticks. |
0.25
|
ticklength |
float
|
Length of ticks. |
3
|
ticklabelpad |
float
|
Padding between ticks and labels. |
2
|
spines |
Tuple[str, ...]
|
Tuple of spine names to adjust. |
('top', 'right', 'bottom', 'left')
|
Returns:
Type | Description |
---|---|
None
|
None |
Source code in flyvision/analysis/visualization/plt_utils.py
1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 |
|
flyvision.analysis.visualization.plt_utils.scatter_on_violins_with_best ¶
scatter_on_violins_with_best(
data,
ax,
scatter_best,
scatter_all,
xticks=None,
facecolor="none",
edgecolor="k",
best_scatter_alpha=1.0,
all_scatter_alpha=0.35,
best_index=None,
best_color=None,
all_marker="o",
best_marker="o",
linewidth=0.5,
best_linewidth=0.75,
uniform=[-0.35, 0.35],
**kwargs
)
Scatter data points on violin plots, optionally highlighting the best point.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
ndarray
|
Array of shape (n_samples, n_variables). |
required |
ax |
Axes
|
Matplotlib axes object to plot on. |
required |
scatter_best |
bool
|
Whether to scatter the best point. |
required |
scatter_all |
bool
|
Whether to scatter all points. |
required |
xticks |
Optional[ndarray]
|
X-axis tick positions. |
None
|
facecolor |
Union[str, Tuple[float, float, float]]
|
Color for marker face. |
'none'
|
edgecolor |
Union[str, Tuple[float, float, float]]
|
Color for marker edge. |
'k'
|
best_scatter_alpha |
float
|
Alpha for best point. |
1.0
|
all_scatter_alpha |
float
|
Alpha for all other points. |
0.35
|
best_index |
Optional[int]
|
Index of the best point. |
None
|
best_color |
Optional[Union[str, Tuple[float, float, float]]]
|
Color for the best point. |
None
|
all_marker |
str
|
Marker style for all points. |
'o'
|
best_marker |
str
|
Marker style for the best point. |
'o'
|
linewidth |
float
|
Width of marker edge for all points. |
0.5
|
best_linewidth |
float
|
Width of marker edge for the best point. |
0.75
|
uniform |
List[float]
|
Range for uniform distribution of x-positions. |
[-0.35, 0.35]
|
Returns:
Type | Description |
---|---|
None
|
None |
Source code in flyvision/analysis/visualization/plt_utils.py
1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 |
|
flyvision.analysis.visualization.plt_utils.trim_axis ¶
trim_axis(ax, xaxis=True, yaxis=True)
Trim axis to show only the range of data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ax |
Axes
|
Matplotlib axes object. |
required |
xaxis |
bool
|
Whether to trim x-axis. |
True
|
yaxis |
bool
|
Whether to trim y-axis. |
True
|
Returns:
Type | Description |
---|---|
None
|
None |
Source code in flyvision/analysis/visualization/plt_utils.py
1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 |
|
flyvision.analysis.visualization.plt_utils.display_significance_value ¶
display_significance_value(
ax,
pvalue,
y,
x0=None,
x1=None,
ticklabel=None,
bar_width=0.7,
pthresholds={0.01: "***", 0.05: "**", 0.1: "*"},
fontsize=8,
annotate_insignificant="",
append_tick=False,
show_bar=False,
other_ax=None,
bar_height_ylim_ratio=0.01,
linewidth=0.5,
annotate_pthresholds=True,
loc_pthresh_annotation=(0.1, 0.1),
location="above",
asterisk_offset=None,
)
Display a significance value annotation along x at height y.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ax |
Axes
|
Matplotlib axes object. |
required |
pvalue |
float
|
P-value to display. |
required |
y |
float
|
Height to put text. |
required |
x0 |
Optional[float]
|
Left edge of bar if show_bar is True. |
None
|
x1 |
Optional[float]
|
Right edge of bar if show_bar is True. |
None
|
ticklabel |
Optional[str]
|
Tick label to annotate. |
None
|
bar_width |
float
|
Width of the bar. |
0.7
|
pthresholds |
Dict[float, str]
|
Dictionary of p-value thresholds and corresponding annotations. |
{0.01: '***', 0.05: '**', 0.1: '*'}
|
fontsize |
int
|
Font size for annotations. |
8
|
annotate_insignificant |
str
|
Annotation for insignificant p-values. |
''
|
append_tick |
bool
|
Whether to append annotation to tick label. |
False
|
show_bar |
bool
|
Whether to show a bar above the annotation. |
False
|
other_ax |
Optional[Axes]
|
Another axes object to get tick labels from. |
None
|
bar_height_ylim_ratio |
float
|
Ratio of bar height to y-axis limits. |
0.01
|
linewidth |
float
|
Line width for the bar. |
0.5
|
annotate_pthresholds |
bool
|
Whether to annotate p-value thresholds. |
True
|
loc_pthresh_annotation |
Tuple[float, float]
|
Location of p-value threshold annotation. |
(0.1, 0.1)
|
location |
Literal['above', 'below']
|
Location of annotation (“above” or “below”). |
'above'
|
asterisk_offset |
Optional[float]
|
Offset for asterisk annotation. |
None
|
Returns:
Type | Description |
---|---|
None
|
None |
Source code in flyvision/analysis/visualization/plt_utils.py
1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 |
|
flyvision.analysis.visualization.plt_utils.display_pvalues ¶
display_pvalues(
ax,
pvalues,
ticklabels,
data,
location="above",
bar_width=0.7,
show_bar=True,
bar_height_ylim_ratio=0.01,
fontsize=6,
annotate_insignificant="ns",
loc_pthresh_annotation=(0.01, 0.01),
append_tick=False,
data_relative_offset=0.05,
asterisk_offset=0,
pthresholds={0.01: "***", 0.05: "**", 0.1: "*"},
)
Annotate all p-values from a dictionary of x-tick labels to p-values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ax |
Axes
|
Matplotlib axes object. |
required |
pvalues |
Dict[str, float]
|
Dictionary mapping x-tick labels to p-values. |
required |
ticklabels |
List[str]
|
List of x-tick labels. |
required |
data |
ndarray
|
Array of shape (random variables, …). |
required |
location |
Literal['above', 'below']
|
Location of annotation (“above” or “below”). |
'above'
|
bar_width |
float
|
Width of the bar. |
0.7
|
show_bar |
bool
|
Whether to show a bar above the annotation. |
True
|
bar_height_ylim_ratio |
float
|
Ratio of bar height to y-axis limits. |
0.01
|
fontsize |
int
|
Font size for annotations. |
6
|
annotate_insignificant |
str
|
Annotation for insignificant p-values. |
'ns'
|
loc_pthresh_annotation |
Tuple[float, float]
|
Location of p-value threshold annotation. |
(0.01, 0.01)
|
append_tick |
bool
|
Whether to append annotation to tick label. |
False
|
data_relative_offset |
float
|
Relative offset for annotation placement. |
0.05
|
asterisk_offset |
float
|
Offset for asterisk annotation. |
0
|
pthresholds |
Dict[float, str]
|
Dictionary of p-value thresholds and corresponding annotations. |
{0.01: '***', 0.05: '**', 0.1: '*'}
|
Returns:
Type | Description |
---|---|
None
|
None |
Source code in flyvision/analysis/visualization/plt_utils.py
1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 |
|
flyvision.analysis.visualization.plt_utils.closest_divisors ¶
closest_divisors(n)
Find the closest divisors of a number.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n |
int
|
Number to find divisors for. |
required |
Returns:
Type | Description |
---|---|
Tuple[int, int]
|
Tuple of closest divisors. |
Source code in flyvision/analysis/visualization/plt_utils.py
1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 |
|
flyvision.analysis.visualization.plt_utils.standalone_legend ¶
standalone_legend(
labels,
colors,
legend_elements=None,
alpha=1,
fontsize=6,
fig=None,
ax=None,
lw=4,
labelspacing=0.5,
handlelength=2.0,
n_cols=None,
columnspacing=0.8,
figsize=None,
linestyles=None,
)
Create a standalone legend.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
labels |
List[str]
|
List of labels for legend entries. |
required |
colors |
List[Union[str, Tuple[float, float, float]]]
|
List of colors for legend entries. |
required |
legend_elements |
Optional[List]
|
List of custom legend elements. |
None
|
alpha |
float
|
Alpha value for legend entries. |
1
|
fontsize |
int
|
Font size for legend text. |
6
|
fig |
Optional[Figure]
|
Existing figure to use. |
None
|
ax |
Optional[Axes]
|
Existing axes to use. |
None
|
lw |
float
|
Line width for legend entries. |
4
|
labelspacing |
float
|
Vertical space between legend entries. |
0.5
|
handlelength |
float
|
Length of the legend handles. |
2.0
|
n_cols |
Optional[int]
|
Number of columns in the legend. |
None
|
columnspacing |
float
|
Spacing between legend columns. |
0.8
|
figsize |
Optional[Tuple[float, float]]
|
Figure size (width, height) in inches. |
None
|
linestyles |
Optional[List[str]]
|
List of line styles for legend entries. |
None
|
Returns:
Type | Description |
---|---|
Tuple[Figure, Axes]
|
Tuple containing the figure and axes objects. |
Source code in flyvision/analysis/visualization/plt_utils.py
1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 |
|
flyvision.analysis.visualization.plt_utils.extend_arg ¶
extend_arg(arg, argtype, r, default, dim=-1)
Extend an argument to the correct length for a given dimension.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
arg |
Union[Number, List[Number]]
|
Argument to extend. |
required |
argtype |
type
|
Type of the argument. |
required |
r |
ndarray
|
Reference array for shape. |
required |
default |
Any
|
Default value if arg is not provided. |
required |
dim |
int
|
Dimension to extend along. |
-1
|
Returns:
Type | Description |
---|---|
Union[List[Number], Number]
|
Extended argument. |
Source code in flyvision/analysis/visualization/plt_utils.py
2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 |
|