Skip to content
Projects

tikzfigure.core.scope

Classes

NameDescription
ScopeA TikZ scope block with local options and nested content.

Scopeclass#

class Scope(label: str = '', comment: str | None = None, layer: int = 0, options: OptionInput | None = None, node_resolver: Callable[[str], Node | Coordinate] | None = None, library_loader: Callable[[str], None] | None = None, **kwargs: Any)

Bases: FigurePathMixin, TikzObject

A TikZ scope block with local options and nested content.

coordinateattributeclass attributeinstance attribute#

coordinate = add_coordinate

loopattributeclass attributeinstance attribute#

loop = add_loop

nodeattributeclass attributeinstance attribute#

node = add_node

plotattributeclass attributeinstance attribute#

plot = add_plot

rawattributeclass attributeinstance attribute#

raw = add_raw

scopeattributeclass attributeinstance attribute#

scope = add_scope

spyattributeclass attributeinstance attribute#

spy = add_spy

spy_scopeattributeclass attributeinstance attribute#

spy_scope = add_spy_scope

itemsproperty#

items: list[Any]

addmethod#

def add(items: Any) -> None

Add one or more pre-built TikZ objects to this scope.

Parameters

NameTypeDescription
itemsAnyA single TikZ object or a list/tuple of them.

add_coordinatemethod#

def add_coordinate(label: str, x: Any = None, y: Any = None, z: Any = None, at: str | None = None, comment: str | None = None) -> Coordinate

add_loopmethod#

def add_loop(variable: str, values: list[Any] | tuple[Any, ...] | range, comment: str | None = None) -> Any

add_nodemethod#

def add_node(*args: Any, **kwargs: Any) -> Node

add_plotmethod#

def add_plot(x: Any, y: Any | None = None, *, variable: str = 'x', domain: tuple[Any, Any] | str | None = None, samples: int | None = None, smooth: bool = False, comment: str | None = None, options: OptionInput | None = None, tikz_command: str = 'draw', **kwargs: Any) -> TikzPlot

Add a plain TikZ expression plot inside this scope.

add_rawmethod#

def add_raw(tikz_code: str) -> RawTikz

add_scopemethod#

def add_scope(comment: str | None = None, options: OptionInput | None = None, **kwargs: Any) -> Scope

add_spymethod#

def add_spy(on: Any, *, comment: str | None = None, options: OptionInput | None = None, magnification: float | None = None, lens: OptionInput | str | None = None, lens_kwargs: dict[str, Any] | None = None, size: str | object | None = None, width: str | object | None = None, height: str | object | None = None, connect_spies: bool = False, at: Any = None, node_label: str | None = None, node_options: OptionInput | None = None, node_style: dict[str, Any] | None = None, **kwargs: Any) -> Spy

Add a \spy command inside this scope.

This is the scoped counterpart to TikzFigure.spy(...) and is most useful inside a spy scope created with scope.spy_scope(...) or figure.spy_scope(...).

add_spy_scopemethod#

def add_spy_scope(comment: str | None = None, mode: SpyScopeMode = 'scope', options: OptionInput | None = None, magnification: float | None = None, lens: OptionInput | str | None = None, lens_kwargs: dict[str, Any] | None = None, size: str | object | None = None, width: str | object | None = None, height: str | object | None = None, connect_spies: bool = False, every_spy_in_node_options: OptionInput | None = None, every_spy_in_node_style: dict[str, Any] | None = None, every_spy_on_node_options: OptionInput | None = None, every_spy_on_node_style: dict[str, Any] | None = None, spy_connection_path: str | None = None, **kwargs: Any) -> Scope

Create a nested scope configured for local spy defaults.

The returned scope can be used as a context manager. Its local options are translated to TikZ spy scope, spy using outlines, or spy using overlays settings depending on mode.

copymethod#

def copy(**overrides: Any) -> Scope

from_dictmethodclassmethod#

def from_dict(d: dict[str, Any], node_lookup: dict[str, Node | Coordinate] | None = None) -> Scope

get_nodemethod#

def get_node(node_label: str) -> Node | Coordinate

to_dictmethod#

def to_dict() -> dict[str, Any]

to_tikzmethod#

def to_tikz(output_unit: str | None = None) -> str
Inherited from tikzfigure.core.figure_paths.FigurePathMixin

clipmethod#

def clip(nodes: list, layer: int = 0, comment: str | None = None, center: bool = False, verbose: bool = False, options: OptionInput | None = None, cycle: bool = False, segment_options: list[SegmentOption] | None = None, rotate: float | None = None, xshift: str | None = None, yshift: str | None = None, scale: float | None = None, rounded_corners: str | None = None, **kwargs: Any) -> TikzPath

Add a clipping path using \clip.

drawmethod#

def draw(nodes: list | NodePathBuilder, layer: int = 0, comment: str | None = None, center: bool = False, verbose: bool = False, options: OptionInput | None = None, cycle: bool = False, segment_options: list[SegmentOption] | None = None, color: ColorInput | None = None, fill: ColorInput | None = None, draw: ColorInput | None = None, text: ColorInput | None = None, opacity: float | None = None, draw_opacity: float | None = None, fill_opacity: float | None = None, text_opacity: float | None = None, line_width: str | float | None = None, line_cap: _LineCap = None, line_join: _LineJoin = None, miter_limit: float | None = None, dash_pattern: str | None = None, dash_phase: str | None = None, double: ColorInput | None = None, double_distance: str | None = None, rounded_corners: str | None = None, rotate: float | None = None, xshift: str | None = None, yshift: str | None = None, scale: float | None = None, xscale: float | None = None, yscale: float | None = None, xslant: float | None = None, yslant: float | None = None, bend_left: float | None = None, bend_right: float | None = None, in_angle: float | None = None, out_angle: float | None = None, looseness: float | None = None, in_looseness: float | None = None, out_looseness: float | None = None, min_distance: str | None = None, max_distance: str | None = None, tension: float | None = None, pattern: _Pattern = None, pattern_color: ColorInput | None = None, shading: _Shading = None, shading_angle: float | None = None, left_color: ColorInput | None = None, right_color: ColorInput | None = None, top_color: ColorInput | None = None, bottom_color: ColorInput | None = None, middle_color: ColorInput | None = None, inner_color: ColorInput | None = None, outer_color: ColorInput | None = None, ball_color: ColorInput | None = None, decoration: _Decoration = None, step: str | None = None, pos: float | None = None, arrows: ArrowInput | None = None, font: str | None = None, name_path: str | None = None, to_path: str | None = None, domain: str | None = None, samples: int | None = None, mark: _Mark = None, mark_size: str | None = None, **kwargs: Any) -> TikzPath

Add a path connecting multiple nodes with \draw.

fillmethod#

def fill(nodes: list, layer: int = 0, comment: str | None = None, center: bool = False, verbose: bool = False, options: OptionInput | None = None, cycle: bool = False, segment_options: list[SegmentOption] | None = None, fill: ColorInput | None = None, fill_opacity: float | None = None, opacity: float | None = None, pattern: _Pattern = None, pattern_color: ColorInput | None = None, shading: _Shading = None, shading_angle: float | None = None, left_color: ColorInput | None = None, right_color: ColorInput | None = None, top_color: ColorInput | None = None, bottom_color: ColorInput | None = None, middle_color: ColorInput | None = None, inner_color: ColorInput | None = None, outer_color: ColorInput | None = None, ball_color: ColorInput | None = None, rotate: float | None = None, xshift: str | None = None, yshift: str | None = None, scale: float | None = None, xscale: float | None = None, yscale: float | None = None, even_odd_rule: bool = False, **kwargs: Any) -> TikzPath

Fill a closed path with no stroke using \fill.

filldrawmethod#

def filldraw(nodes: list | NodePathBuilder, layer: int = 0, comment: str | None = None, center: bool = False, verbose: bool = False, options: OptionInput | None = None, cycle: bool = False, segment_options: list[SegmentOption] | None = None, color: ColorInput | None = None, fill: ColorInput | None = None, draw: ColorInput | None = None, text: ColorInput | None = None, opacity: float | None = None, draw_opacity: float | None = None, fill_opacity: float | None = None, text_opacity: float | None = None, line_width: str | None = None, line_cap: _LineCap = None, line_join: _LineJoin = None, miter_limit: float | None = None, dash_pattern: str | None = None, dash_phase: str | None = None, double: ColorInput | None = None, double_distance: str | None = None, rounded_corners: str | None = None, rotate: float | None = None, xshift: str | None = None, yshift: str | None = None, scale: float | None = None, xscale: float | None = None, yscale: float | None = None, xslant: float | None = None, yslant: float | None = None, bend_left: float | None = None, bend_right: float | None = None, in_angle: float | None = None, out_angle: float | None = None, looseness: float | None = None, in_looseness: float | None = None, out_looseness: float | None = None, min_distance: str | None = None, max_distance: str | None = None, tension: float | None = None, pattern: _Pattern = None, pattern_color: ColorInput | None = None, shading: _Shading = None, shading_angle: float | None = None, left_color: ColorInput | None = None, right_color: ColorInput | None = None, top_color: ColorInput | None = None, bottom_color: ColorInput | None = None, middle_color: ColorInput | None = None, inner_color: ColorInput | None = None, outer_color: ColorInput | None = None, ball_color: ColorInput | None = None, decoration: _Decoration = None, step: str | None = None, pos: float | None = None, arrows: ArrowInput | None = None, font: str | None = None, name_path: str | None = None, to_path: str | None = None, domain: str | None = None, samples: int | None = None, mark: _Mark = None, mark_size: str | None = None, **kwargs: Any) -> TikzPath

Add a filled path connecting multiple nodes with \filldraw.

pathmethod#

def path(nodes: list, layer: int = 0, comment: str | None = None, center: bool = False, verbose: bool = False, options: OptionInput | None = None, cycle: bool = False, segment_options: list[SegmentOption] | None = None, name_path: str | None = None, pos: float | None = None, rotate: float | None = None, xshift: str | None = None, yshift: str | None = None, scale: float | None = None, **kwargs: Any) -> TikzPath

Add an invisible path using \path.

Inherited from tikzfigure.core.base.TikzObject

commentproperty#

comment: str | None

Comment prepended to the generated TikZ code, or None.

kwargsproperty#

kwargs: dict

Keyword-style TikZ options as a plain dict.

labelproperty#

label: str | None

Unique identifier for this object within the figure.

layerproperty#

layer: int | None

Layer index this object belongs to.

optionsproperty#

options: list[OptionValue]

Flag-style TikZ options without values.

add_commentmethod#

def add_comment(string_in: str) -> str

Prepend a TikZ comment line to a string if a comment is set.

Parameters

NameTypeDescription
string_instrThe TikZ code string to annotate.

Returns

str
The original string prefixed with % <comment>\n when a
str
comment is set, otherwise the string unchanged.

tikz_optionsmethod#

def tikz_options(output_unit: str | None = None) -> str

Render all options as a single TikZ option string.

Combines flag-style options and keyword options into the format expected inside TikZ square brackets, e.g. "thick, color=red, line width=1pt".

Parameters

NameTypeDefaultDescription
output_unitstr | NoneNoneIf provided, any :class:~tikzfigure.units.TikzDimension values are converted to this unit before rendering.

Returns

str
A comma-separated string of TikZ options.