tweak
Functors to tweak callout leader layout.
Classes
Functor to change orientation of callout via reflection. |
|
Functor to spread apart a crowded axes area. |
- class TweakReflect[source]
Functor to change orientation of callout via reflection.
The adjustment is applied by reflecting the leader vertices about the centroid of the frame. Horizontal and/or vertical reflection can be specified.
- __init__(*, horizontal: bool | None = None, vertical: bool | None = None) None [source]
Initialize the TweakReflect functor.
If neither horizontal or vertical are specified, a horizontal reflection will be performed.
- Parameters:
horizontal (Optional[bool]) – Should the callout leader be reflected horizontally?
vertical (Optional[Tuple[float, float]], optional) – Should the callout leader be reflected vertically?
- __call__(leader_vertices: Sequence[Tuple[float, float]], ax: Axes | None = None) List[Tuple[float, float]] [source]
Reflect leader vertices about centroid.
- Parameters:
leader_vertices (Sequence[Tuple[float, float]]) – A sequence of tuples representing the (x, y) coordinates of the leader vertices.
ax (mpl_axes.Axes) –
The matplotlib Axes object on which the leader vertices are plotted.
Not used for this tweak.
- Returns:
The updated leader vertices.
- Return type:
List[Tuple[float, float]]
- class TweakSpreadArea[source]
Functor to spread apart a crowded axes area.
The adjustment is applied by moving the vertex away from the centroid of the parametrized x/y limits, scaled by a spread factor.
- __init__(spread_factor: float | Tuple[float, float] = 2.0, *, xlim: Tuple[float, float] | None = None, ylim: Tuple[float, float] | None = None) None [source]
Initialize the TweakSpreadArea functor.
- Parameters:
spread_factor (Union[float, Tuple[float, float]], optional) –
How aggressively to spread apart x and/or y coordinates.
If a tuple is provided, the first element is used for x-coordinate spread and the second for y-coordinate spread. If a single float is provided, it is used for both.
xlim (Optional[Tuple[float, float]], optional) – If provided, outer vertices falling within the x-coordinate range will be spread horizontally away from the range’s centroid.
ylim (Optional[Tuple[float, float]], optional) – If provided, outer vertices falling within the y-coordinate range will be spread vertically away from the range’s centroid.
- __call__(leader_vertices: Sequence[Tuple[float, float]], ax: Axes | None = None) List[Tuple[float, float]] [source]
Spread outer vertex of leader polygon out from specied area.
- Parameters:
leader_vertices (Sequence[Tuple[float, float]]) – A sequence of tuples representing the (x, y) coordinates of the leader vertices.
ax (mpl_axes.Axes) –
The matplotlib Axes object on which the leader vertices are plotted.
Not used for this tweak.
- Returns:
The modified sequence of leader vertices with the outer vertex position adjusted.
- Return type:
List[Tuple[float, float]]