text#
- named_arrays.plt.text(x, y, s, ax=None, **kwargs)#
A thin wrapper around
matplotlib.axes.Axes.text()for named arrays.- Parameters:
x (float | Quantity | AbstractScalar) – The horizontal position of the text in data coordinates.
y (float | Quantity | AbstractScalar) – The vertical position of the text in data coordinates.
s (str | AbstractScalar) – The text to plot.
ax (None | Axes | AbstractScalar) – The matplotlib axes instance on which to plot the text.
kwargs – Additional keyword arguments to pass to
matplotlib.axes.Axes.text().
- Return type:
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);