text#

named_arrays.plt.text(x, y, s, ax=None, **kwargs)#

A thin wrapper around matplotlib.axes.Axes.text() for named arrays.

Parameters:
Return type:

AbstractScalar

Examples

Plot an array of text values at different locations.

import numpy as np
import matplotlib.pyplot as plt
import astropy.units as u
import named_arrays as na

# Create an array of azimuths where the next will be placed
azimuth = na.linspace(0, 360, axis="azimuth", num=4, endpoint=False) * u.deg

# Compute the x and y coordinates for the given azimuth
x = np.cos(azimuth)
y = np.sin(azimuth)

# Create an array of strings to plot at the chosen positions
s = na.ScalarArray(
    ndarray=np.array(["East", "North", "West", "South"]),
    axes="azimuth"
)

# Plot the array of strings
fig, ax = plt.subplots()
na.plt.text(
    x=x,
    y=y,
    s=s,
    ax=ax,
);
ax.set_xlim(-2, 2);
ax.set_ylim(-2, 2);
../_images/named_arrays.plt.text_0_0.png