Render options (grouped parameters)#
Glyph plot() / animate() calls take these typed objects in place of loose keyword arguments.
Each bundles a family of related options and exposes to_options(), which the glyph flattens into
its render settings — only the fields you set are applied, so a group never clobbers a glyph's own
defaults. (The ArrayGlyph-specific input objects — RgbBands, PointOverlay, FrameLabel,
PanelLabels — are documented on the ArrayGlyph page.)
ColorScaling#
The colour-scale (norm) selector: plot(color=ColorScaling.power(gamma=0.5)),
ColorScaling.sym_log(...), ColorScaling.boundary(bounds=[...]), ColorScaling.midpoint(at=0),
ColorScaling.linear().
cleopatra.styling.scaling.ColorScaling
dataclass
#
The colour-scale group: a scale kind plus its scale-specific knobs.
Prefer the variant constructors (linear, power, sym_log, log,
boundary, midpoint, equalize) over the raw dataclass -- each exposes
only the fields its scale uses, so nonsensical combinations (e.g. a
midpoint on a linear scale) cannot be built.
Attributes:
| Name | Type | Description |
|---|---|---|
kind |
ColorScale
|
The scale kind ( |
gamma |
float
|
Exponent for the |
line_threshold |
float | None
|
Linear-region threshold ( |
line_scale |
float | None
|
Linear-region scale factor ( |
bounds |
list[float] | None
|
Explicit bin edges for |
center |
float
|
Centre value for the |
samples |
int
|
Number of quantile samples for the |
Source code in src/cleopatra/styling/scaling.py
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 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 588 589 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 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 | |
boundary(bounds=None)
classmethod
#
A discrete (BoundaryNorm) colour scale.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bounds
|
list[float] | None
|
Explicit bin edges. When |
None
|
Examples:
- Explicit edges are carried through:
Source code in src/cleopatra/styling/scaling.py
build_norm(ticks, levels=None, extend=None, values=None)
#
Build the matplotlib norm and colorbar keyword arguments.
The colour-scale logic that used to live in
Glyph._create_norm_and_cbar_kw. vmin/vmax are read from the
first and last tick; levels and extend are cross-group inputs
(contour discretisation and colorbar arrow extension) passed in by
the caller.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ticks
|
ndarray
|
Tick positions for the colorbar; |
required |
levels
|
int | list[float] | ndarray | None
|
Optional discretisation for the |
None
|
extend
|
str | None
|
Colorbar arrow extension. When |
None
|
values
|
ndarray | None
|
The data's own values, used only by the |
None
|
Returns:
| Type | Description |
|---|---|
tuple[Normalize | None, dict[str, Any]]
|
tuple[Normalize or None, dict]: The norm ( |
Examples:
- A linear scale with no levels yields no norm and passes the ticks straight through:
levelson the linear scale builds aBoundaryNormand defaultsextendto"both":
Source code in src/cleopatra/styling/scaling.py
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 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 | |
equalize(samples=512)
classmethod
#
A continuous rank-equalising colour scale (histogram equalisation).
Spreads the colour ramp by rank rather than by value, so every quantile
of the data receives an equal share of the ramp. On a skewed field
(bathymetry, population, discharge) this reveals the bulk that a linear
norm flattens into one tone -- and, unlike boundary, it stays
continuous, so it does not posterise a shaded-relief surface. It is
backed by a matplotlib.colors.FuncNorm built from the data's own
empirical CDF at render time.
It ranks within the resolved display window, so vmin/vmax and
robust=True clip the field before ranking (handy for taming outliers
on a skewed surface); with no limits it ranks the whole field.
The scale is data-driven, so it is wired for ArrayGlyph (which can
supply its cell values); using it where the values are unavailable
raises a clear error rather than guessing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
samples
|
int
|
Number of quantile samples in the empirical-CDF table --
its resolution. Must be at least 2. Defaults to |
512
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Examples:
- The equalize scale carries its sample count:
Source code in src/cleopatra/styling/scaling.py
from_options(options)
classmethod
#
Build a ColorScaling from a flat default_options dict.
The bridge between the legacy flat-key storage every glyph still
uses internally and this object's behaviour. Reads the six
colour-scale keys, validating color_scale with the same
actionable error the flat path raised.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
options
|
dict[str, Any]
|
A glyph's |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ColorScaling |
ColorScaling
|
The reconstructed scale object. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Examples:
- Round-trips the flat keys back into an object:
Source code in src/cleopatra/styling/scaling.py
linear()
classmethod
#
A plain linear colour scale (matplotlib's default norm).
Examples:
- The linear scale carries no extra knobs:
Source code in src/cleopatra/styling/scaling.py
log()
classmethod
#
A logarithmic (LogNorm) colour scale for strictly-positive data.
The plain-log counterpart of sym_log: LogNorm needs a positive
value range, so for data that spans zero or negative values use
sym_log (a symmetric-log scale) instead. Like linear, it carries
no extra knobs -- vmin/vmax come from the tick range at render
time.
On ArrayGlyph, an un-pinned vmin is floored at the smallest positive
value that is not an extreme low outlier (ArrayGlyph._log_safe_vmin),
so a lone near-zero pixel does not drag the bar's decades below the
data's bulk (issue #339); pass an explicit vmin to keep the raw
minimum.
Examples:
- The log scale exposes no extra knobs:
Source code in src/cleopatra/styling/scaling.py
midpoint(at=0)
classmethod
#
A midpoint-anchored diverging colour scale.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
at
|
float
|
The value pinned to the colormap centre. Defaults to |
0
|
Examples:
- Anchor the colormap centre at a chosen value:
Source code in src/cleopatra/styling/scaling.py
power(gamma=0.5)
classmethod
#
A power-law (PowerNorm) colour scale.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gamma
|
float
|
The power exponent. Defaults to |
0.5
|
Examples:
- Only
gammais exposed:
Source code in src/cleopatra/styling/scaling.py
sym_log(threshold=None, scale=None)
classmethod
#
A symmetric-log (SymLogNorm) colour scale.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
threshold
|
float | None
|
The linear-region half-width ( |
None
|
scale
|
float | None
|
The linear-region scale factor ( |
None
|
Examples:
- Exposes the two
sym-lognormknobs: - The default defers the threshold to the data range:
Source code in src/cleopatra/styling/scaling.py
to_options()
#
Flatten back to the default_options keys the engine reads.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict[str, Any]
|
The colour-scale keys, with |
Examples:
- Emits the flat keys a glyph merges into
default_options:
Source code in src/cleopatra/styling/scaling.py
Contour#
Discrete colour levels and inline contour labels: plot(contour=Contour(levels=6, labels=True)). Also a
hatch encoding — a pattern per band for marking a region without spending the colour channel; fill=False
draws the hatching alone, the significance/uncertainty overlay form:
plot(kind="contourf", contour=Contour(levels=[0.5, 1.5], hatches=["///"], fill=False, hatch_color="0.2")).
cleopatra.styling.params.Contour
dataclass
#
Contour discretisation and inline-label options.
Groups the levels / labels / label_kw options plus the hatch
encoding (hatches / fill / hatch_color). levels applies to every
colour-mapped glyph that discretises a scale (array, vector, flow,
polygon, scatter, kde); labels / label_kw draw inline numeric labels
on isolines and are honoured only by the glyphs that render contour lines
(ArrayGlyph with kind="contour", MeshGlyph node contours). The hatch
fields draw a pattern per band on the contourf path (ArrayGlyph
today), so a mask can be marked without spending the colour channel --
fill=False leaves only the hatching, the significance/uncertainty
overlay form.
Attributes:
| Name | Type | Description |
|---|---|---|
levels |
int | Sequence[float] | None
|
Discrete colour levels -- an int count or an explicit
sequence of edges. |
labels |
bool | None
|
Draw inline numeric labels on isolines. |
label_kw |
dict[str, Any] | None
|
Extra keyword arguments forwarded to |
hatches |
Sequence[str | None] | None
|
A hatch pattern per band, e.g. |
fill |
bool | None
|
|
hatch_color |
str | None
|
Colour of the hatch strokes for this set only, applied
via |
Examples:
- Only the set fields are emitted:
- A hatch overlay emits its own keys and nothing else:
Source code in src/cleopatra/styling/params.py
to_options()
#
Flatten the explicitly-set fields into default_options keys.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict[str, Any]
|
|
Source code in src/cleopatra/styling/params.py
CellValues#
Per-cell value-text overlay (ArrayGlyph): plot(cells=CellValues(show=True, size=10)).
cleopatra.styling.params.CellValues
dataclass
#
Per-cell value-text display options (ArrayGlyph only).
Groups the display_cell_value / num_size /
background_color_threshold options that overlay each cell's numeric
value on an imshow / pcolormesh render.
Attributes:
| Name | Type | Description |
|---|---|---|
show |
bool | None
|
Draw each cell's value as text. |
size |
int | None
|
Font size of the cell-value text. |
background_threshold |
float | None
|
Value above which the text switches to the
light colour (for contrast against a dark cell). |
Examples:
- Enable the overlay with a custom font size:
Source code in src/cleopatra/styling/params.py
to_options()
#
Flatten the explicitly-set fields into default_options keys.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict[str, Any]
|
|
Source code in src/cleopatra/styling/params.py
DataStyle#
Named preset, relief shading, and per-call preset overrides:
plot(data_style=DataStyle(style="topography", hillshade=True)).
cleopatra.styling.params.DataStyle
dataclass
#
Named data-style preset, relief-shading, and per-call preset overrides.
Groups the style / hillshade options honoured by ArrayGlyph,
MeshGlyph, and KDEGlyph, plus the bands / alpha / alpha_range
per-call overrides of an active ArrayGlyph preset. Each field has three
states: left unset (keep the glyph's current value -- these options are
sticky), set to a value (apply it), or set explicitly to None (clear the
preset / disable hillshade / drop the override). to_options() emits a key
only for a field that was given (set or explicit None), never for an
unset one.
The bands / alpha / alpha_range fields override just one aspect of a
styled render while keeping the rest of the preset; they are only
meaningful alongside a style (they replace one field of the active
DATA_STYLES preset). bands rebands the scale (replacing the preset's
levels); alpha sets a constant opacity and alpha_range a value-linked
one -- the two are mutually exclusive and resolved downstream (a constant
alpha wins). They apply to a continuous/levelled preset only; a
categorical (class-colour) preset renders opaque with its fixed class
colours and ignores these overrides.
Attributes:
| Name | Type | Description |
|---|---|---|
style |
str | None | _Unset
|
Name of a |
hillshade |
bool | dict[str, Any] | None | _Unset
|
Relief-shade a regular-grid DEM -- |
bands |
int | None | _Unset
|
Discrete band count partitioning the preset's value range,
replacing the preset's own |
alpha |
float | None | _Unset
|
Constant layer opacity in |
alpha_range |
tuple[float, float] | None | _Unset
|
|
Examples:
- Select a preset and turn on relief shading:
- Override a styled preset's banding and opacity per call:
- An unset field is omitted (keeping the sticky value); an
explicit
Noneis emitted (clearing it):
Source code in src/cleopatra/styling/params.py
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 | |
__post_init__()
#
Validate alpha_range is a (vmin, vmax) numeric pair when given.
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
Source code in src/cleopatra/styling/params.py
for_apply_style(style, hillshade=_UNSET)
classmethod
#
Build the DataStyle an apply_style(...) call forwards to plot.
Folds a preset style and an optionally-forwarded hillshade into one
object: when hillshade is left unset (the default sentinel) it is
omitted so any sticky relief shading is kept; an explicit value (a dict,
True/False, or None to clear) flows through to
DataStyle(hillshade=...). Centralises the sentinel-gated construction
that the apply_style helpers of ArrayGlyph, MeshGlyph, and
KDEGlyph previously each hand-rolled with their own sentinels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
style
|
str | None
|
The |
required |
hillshade
|
bool | dict[str, Any] | None | _Unset
|
Relief-shading override, or the |
_UNSET
|
Returns:
| Name | Type | Description |
|---|---|---|
DataStyle |
DataStyle
|
|
Examples:
>>> from cleopatra.styling.params import DataStyle
>>> DataStyle.for_apply_style("dem").to_options()
{'style': 'dem'}
>>> DataStyle.for_apply_style("dem", hillshade=True).to_options()
{'style': 'dem', 'hillshade': True}
Source code in src/cleopatra/styling/params.py
to_options()
#
Flatten the explicitly-given fields into default_options keys.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict[str, Any]
|
|
Source code in src/cleopatra/styling/params.py
Classify#
Classed colour schemes on the scatter / vector / flow / polygon glyphs and on the raster
ArrayGlyph (plot / facet / animate): plot(classify=Classify(scheme="quantiles", k=5)).
ArrayGlyph bins its 2-D field into the same discrete classes with a stepped colorbar — a named
scheme, or explicit edges Classify(scheme=[0, 10, 50, 100, 500]) — resolving the classes once over
the whole stack when faceting / animating. Its scheme="categorical" is rejected (a raster's cells
are a continuous field, not nominal labels).
cleopatra.styling.params.Classify
dataclass
#
Value-classification (choropleth) options.
Groups the scheme / k / category_legend_kwargs options honoured
by the glyphs whose colour mapping routes through
Glyph._prepare_scalar_mapping -- VectorGlyph, FlowGlyph,
PolygonGlyph, ScatterGlyph -- and by ArrayGlyph, which bins its
2-D field into the same discrete colour classes on plot / facet /
animate (its scheme="categorical" is rejected, since a raster's cells
are a continuous field rather than nominal labels).
Attributes:
| Name | Type | Description |
|---|---|---|
scheme |
str | Sequence[float] | None
|
A |
k |
int | None
|
The class count for count/width schemes. |
category_legend_kwargs |
dict[str, Any] | None
|
Extra keyword arguments forwarded to the
legend a |
Examples:
- A quantile scheme with four classes:
Source code in src/cleopatra/styling/params.py
to_options()
#
Flatten the explicitly-set fields into default_options keys.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict[str, Any]
|
|
Source code in src/cleopatra/styling/params.py
ColorBar#
Colorbar placement, caption, and sizing: plot(colorbar=ColorBar(location="bottom", label="mm/day")).
Pass colorbar=True/False for the simple cases.
cleopatra.styling.colorbar.ColorBar
#
Placement (and backing box) for the colorbar plot / animate draws.
Bundles the colorbar-layout choices -- which edge it sits on, whether it
is inset inside the frame, and its backing box -- into one value passed
as plot(colorbar=...) / animate(colorbar=...), mirroring FrameLabel.
Pass colorbar=True / False / None for the simple cases and a
ColorBar for placement control.
Attributes:
| Name | Type | Description |
|---|---|---|
location |
Edge the colorbar sits on -- |
|
orientation |
Bar orientation -- |
|
inside |
When |
|
box |
Backing panel behind the scale, so the data does not show through
its labels. |
|
label_color |
Colour of the scale's title text -- the colorbar's axis
label and, for a |
|
tick_color |
Colour of the tick labels (the numbers) of a real colorbar
and, for a |
|
label |
Caption text for the scale (the colorbar's title). |
|
length |
Bar length as a fraction of the axis (e.g. |
|
label_size |
Font size of the caption. |
|
label_rotation |
Rotation of the caption in degrees. |
|
label_location |
Where the caption sits along the bar (e.g. |
|
ticks_spacing |
Spacing between the colorbar's ticks. |
Examples:
- An inside colorbar on the right -- its box defaults on:
- Black title + tick numbers, outside on the bottom (no box):
- A captioned bar, fully specified through the spec (no loose kwargs):
Source code in src/cleopatra/styling/colorbar.py
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 | |
__init__(*, location=None, orientation=None, inside=False, box=None, label_color=None, tick_color=None, label=None, length=None, label_size=None, label_rotation=None, label_location=None, ticks_spacing=None)
#
Initialise a ColorBar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
location
|
Literal['left', 'right', 'top', 'bottom'] | None
|
Edge to sit on ( |
None
|
orientation
|
Literal['vertical', 'horizontal'] | None
|
Bar orientation ( |
None
|
inside
|
bool
|
Inset the colorbar inside the frame, by default |
False
|
box
|
bool | str | dict | None
|
Backing panel for an inside colorbar ( |
None
|
label_color
|
str | None
|
Colour of the scale title / colorbar label (and the
swatch title for a |
None
|
tick_color
|
str | None
|
Colour of the colorbar's tick numbers; |
None
|
label
|
str | None
|
Caption text (scale title); |
None
|
length
|
float | None
|
Bar length as a fraction of the axis; |
None
|
label_size
|
float | None
|
Caption font size; |
None
|
label_rotation
|
float | None
|
Caption rotation in degrees; |
None
|
label_location
|
str | None
|
Caption placement along the bar (distinct from
|
None
|
ticks_spacing
|
float | None
|
Spacing between the colorbar's ticks; |
None
|
Source code in src/cleopatra/styling/colorbar.py
reset_options()
classmethod
#
default_options updates for a default, sticky-clearing colorbar.
The dict colorbar=True applies: it draws a default bar and resets the
resettable cbar_* family to STYLE_DEFAULTS, so a reused glyph does
not inherit a prior sticky spec's placement or caption. Distinct from
to_options, which maps a specific spec's fields and omits unset
ones; this resets the whole cbar_* family to the defaults.
ticks_spacing is deliberately excluded: it is glyph-specific
(KDEGlyph, for one, auto-derives it from the data range when unset),
so a single shared reset value could not restore each glyph's own
default -- it is therefore left untouched by colorbar=True.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
|
Examples:
- The reset always enables the bar and clears the placement:
Source code in src/cleopatra/styling/colorbar.py
resolve(colorbar)
classmethod
#
Translate a colorbar= argument into default_options updates.
Owns the full None / False / True / ColorBar dispatch: None
leaves the colorbar options untouched; False suppresses the bar;
True resets to a default bar via reset_options; a ColorBar
instance maps its fields via to_options.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
colorbar
|
bool | ColorBar | None
|
|
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Updates to merge into |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
Examples:
>>> from cleopatra.styling.colorbar import ColorBar
>>> ColorBar.resolve(False)
{'add_colorbar': False}
>>> ColorBar.resolve(ColorBar(location="left", inside=True))["cbar_location"]
'left'
>>> "cbar_label" in ColorBar.resolve(ColorBar(location="right"))
False
Source code in src/cleopatra/styling/colorbar.py
specifies_placement()
#
Whether this spec explicitly requests a placement or orientation.
True when any of location, inside, or orientation is set -- the
spec asks for a specific colorbar rather than leaving the default. Used
to decide whether a styled (preset) render should still draw a colorbar.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
Examples:
- A placement edge counts as specified; a bare spec does not:
Source code in src/cleopatra/styling/colorbar.py
to_options()
#
Map this spec's fields onto the cbar_* default_options keys.
Mirrors the other grouped styling objects' to_options: the object
owns the translation from its own fields to the flat render options
create_color_bar reads. Placement fields are always emitted (so a
reused glyph's prior placement is overwritten); the caption / sizing /
orientation / tick-spacing fields are emitted only when set, leaving an
unset field at the existing default.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
|
Examples:
- Placement maps onto
cbar_*; unset caption fields are omitted:
Source code in src/cleopatra/styling/colorbar.py
Composing onto one axes (compose=)#
By default a glyph drawn onto an axes replaces whatever a glyph put there before it. That is deliberate: a second glyph bound to an existing axes would otherwise leave the first one's artists attached and driven by nothing, which is what once froze an animation at its first frame.
Pass compose=True to draw over what is already there instead — the classic
scalar field with wind arrows on top:
fig, ax = plt.subplots()
temperature.plot(ax=ax, colorbar=ColorBar(label="500 hPa T [C]"))
VectorGlyph(xx, yy, u, v, ax=ax, thin=4).plot(kind="quiver", ax=ax, compose=True)
Three methods accept it: ArrayGlyph.plot, ArrayGlyph.animate and
VectorGlyph.plot. Every other glyph replaces unconditionally, so passing
compose= to one of them is a TypeError.
A composing render clears only the artists it put there itself, so the host's layers, colorbar, title, ticks and projection frame all survive. A glyph replotting onto its own axes still replaces its own artists either way, so nothing is orphaned.
The overlay also draws no colorbar of its own, since a second colorbar would
take its space from the host axes and re-lay it out on every overlay. Pass
add_colorbar=True (or a colorbar= spec) if the overlay should have one
anyway.
Thinning a vector field (thin=)#
quiver and barbs draw one arrow per grid point, which on a real grid is both
unreadable and slow — a 141x321 window is 45,261 arrows. thin=n draws every
nth point along each axis:
thin is a construction-time option like density and scale, not a plot()
argument.
It applies to quiver and barbs. streamplot seeds its own lines and has no
per-point arrow to drop, so thin warns there — use density= instead.