cachai.gadgets.PolarText

class cachai.gadgets.PolarText(radius, angle, text, center=(0, 0), pad=0.0, **kwargs)[source]

Bases: Text

Initialize a matplotlib.text.Text instance using polar coordinates.

Attributes
radiusfloat

Radius coordinate from the center.

thetafloat

Angle in degrees (0° at positive x-axis, increasing counterclockwise).

textstr

Text to diplay.

centertuple, optional

Center coordinates (x,y) (default: (0,0)).

padfloat, optional

Padding value (positive for outward displacement, negative for inward).

Other Attributes
**kwargs

Keyword arguments of matplotlib.text.Text.

Examples

import matplotlib.pyplot as plt
import cachai.gadgets as chg

fig, ax = plt.subplots()
ax.plot([0,0],[1,1])
polar = chg.PolarText((0,0),1,45,text='Im polar!',pad=0.5,ha='center', va='center')
ax.add_artist(polar)
plt.show()

Methods

set_angle(angle)[source]

Changes the angular position of the text around the center.

Parameters
anglefloat

New angle coordinate in degrees.

set_center(center)[source]

Moves the entire polar coordinate system to a new center point.

Parameters
centertuple or array-like

New center coordinates (x,y).

set_pad(pad)[source]

Adjusts the radial padding distance between the text and its base polar position.

Parameters
padfloat

New padding value.

set_polar_position(radius=None, angle=None, center=None)[source]

Updates multiple polar coordinates simultaneously.

Parameters
radiusfloat

New radial distance from center.

anglefloat

New angular position in degrees.

centertuple or array-like

New center coordinates for the polar system.

set_radius(radius)[source]

Updates the radial coordinate of the text relative to the center point.

Parameters
radiusfloat

New radius coordinate.