qten_plots.plottables
Module reference for qten_plots.plottables.
plottables
Plot-ready objects used by QTen plotting backends.
This module defines lightweight containers that carry both geometry data and backend-independent display preferences. Backend implementations can then read the same object and translate its styling fields into Matplotlib or Plotly arguments without changing the underlying QTen geometry objects.
PointCloud
dataclass
PointCloud(
offsets: FrozenSet[Offset] = frozenset(),
name: str | None = None,
color: str | None = None,
marker: str | None = None,
opacity: float | None = None,
size: float | None = None,
border_color: str | None = None,
border_width: float | None = None,
)
Bases: Plottable
Plottable collection of spatial offsets with optional display styling.
A PointCloud groups
Offset objects that should be rendered
together as one scatter trace. The object stores backend-independent style
hints; each plotting backend maps those hints onto its own marker, color,
opacity, size, and border options.
Marker aliases
The marker field accepts the common aliases o, circle, s, square,
d, D, diamond, +, plus, cross, and x. These are normalized to
the marker vocabulary supported by each backend.
Attributes:
| Name | Type | Description |
|---|---|---|
offsets |
FrozenSet[Offset]
|
Spatial offsets to render as a single point cloud. The set is normalized
to a |
name |
str | None
|
Optional trace or legend label. |
color |
str | None
|
Optional backend color value used for all points in the cloud. |
marker |
str | None
|
Optional marker shape alias. |
opacity |
float | None
|
Optional marker opacity in the inclusive range |
size |
float | None
|
Optional positive marker size. |
border_color |
str | None
|
Optional marker border color. |
border_width |
float | None
|
Optional non-negative marker border width. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If any entry in |
ValueError
|
If |
offsets
class-attribute
instance-attribute
offsets: FrozenSet[Offset] = field(
default_factory=frozenset
)
Spatial offsets to render as a single point cloud. The set is normalized
to a frozenset during initialization so the plottable is immutable and
hashable.
name
class-attribute
instance-attribute
name: str | None = None
Optional trace or legend label shown by plotting backends.
color
class-attribute
instance-attribute
color: str | None = None
Optional backend color value applied uniformly to all points in the cloud.
marker
class-attribute
instance-attribute
marker: str | None = None
Optional marker shape alias, normalized to the vocabulary supported by the selected plotting backend.
opacity
class-attribute
instance-attribute
opacity: float | None = None
Optional marker opacity in the inclusive range [0, 1], forwarded as a
backend-independent styling hint.
size
class-attribute
instance-attribute
size: float | None = None
Optional positive marker size shared by every rendered point.
border_color
class-attribute
instance-attribute
border_color: str | None = None
Optional marker border color used by backends that support outlines.
border_width
class-attribute
instance-attribute
border_width: float | None = None
Optional non-negative marker border width used by backends that support marker outlines.
__post_init__
__post_init__()
Source code in ext/plots/src/qten_plots/plottables.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
of
classmethod
of(
offsets: Iterable[Offset],
name: str | None = None,
color: str | None = None,
marker: str | None = None,
opacity: float | None = None,
size: float | None = None,
border_color: str | None = None,
border_width: float | None = None,
) -> PointCloud
Construct a PointCloud from any iterable of offsets.
This helper is convenient when the offsets are produced by an iterator or generator. It freezes the iterable into the immutable set stored by the dataclass.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
offsets
|
Iterable[Offset]
|
Spatial offsets to render as one point cloud. |
required |
name
|
str | None
|
Optional trace or legend label. |
None
|
color
|
str | None
|
Optional backend color value used for all points in the cloud. |
None
|
marker
|
str | None
|
Optional marker shape alias. |
None
|
opacity
|
float | None
|
Optional marker opacity in the inclusive range |
None
|
size
|
float | None
|
Optional positive marker size. |
None
|
border_color
|
str | None
|
Optional marker border color. |
None
|
border_width
|
float | None
|
Optional non-negative marker border width. |
None
|
Returns:
| Type | Description |
|---|---|
PointCloud
|
New immutable point cloud containing the provided offsets. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If any entry in |
ValueError
|
If |
Source code in ext/plots/src/qten_plots/plottables.py
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 | |
register_plot_method
classmethod
register_plot_method(name: str, backend: str = 'plotly')
Register a backend plotting function for this plottable class.
The returned decorator stores the function in the global plotting
registry. Registered functions receive the object being plotted as their
first argument, followed by any extra positional and keyword arguments
supplied to plot().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
User-facing plot method name, such as |
required |
backend
|
str
|
Backend name that selects the implementation. The |
'plotly'
|
Returns:
| Type | Description |
|---|---|
Callable
|
Decorator that registers the provided plotting function and returns it unchanged. |
Source code in src/qten/plottings/_plottings.py
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 | |
plot
plot(method: str, backend: str = 'plotly', *args, **kwargs)
Dispatch a named plot method to a registered backend implementation.
The dispatcher first loads plotting entry points, then searches the
instance type and its base classes for a matching (type, method,
backend) registration. Additional arguments are forwarded unchanged to
the selected backend function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method
|
str
|
Plot method name registered for this object's type. |
required |
backend
|
str
|
Backend implementation to use. The |
'plotly'
|
args
|
Positional arguments forwarded to the registered plotting function. |
()
|
|
kwargs
|
Keyword arguments forwarded to the registered plotting function. |
{}
|
Returns:
| Type | Description |
|---|---|
object
|
Backend-specific figure object returned by the registered plotting function, such as a Plotly or Matplotlib figure. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no plotting function is registered for the requested method and backend on this object. |
See Also
qten_plots.plottables.PointCloud Public plottable helper object provided by the plotting extension.
Source code in src/qten/plottings/_plottings.py
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 | |