Skip to content

Commit a846258

Browse files
committed
change argument from label to text
label is used by matplotlib
1 parent a6bf34e commit a846258

1 file changed

Lines changed: 11 additions & 14 deletions

File tree

‎spatialmath/base/graphics.py‎

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,16 @@ def plot_text(pos, text=None, ax=None, color=None, **kwargs):
7474
return [handle]
7575

7676

77-
def plot_point(pos, marker="bs", label=None, text=None, ax=None, textargs=None, **kwargs):
77+
def plot_point(pos, marker="bs", text=None, ax=None, textargs=None, **kwargs):
7878
"""
7979
Plot a point using matplotlib
8080
8181
:param pos: position of marker
8282
:type pos: array_like(2), ndarray(2,n), list of 2-tuples
8383
:param marker: matplotlub marker style, defaults to 'bs'
8484
:type marker: str or list of str, optional
85-
:param label: text label, defaults to None
86-
:type label: str, optional
85+
:param text: text label, defaults to None
86+
:type text: str, optional
8787
:param ax: axes to plot in, defaults to ``gca()``
8888
:type ax: Axis, optional
8989
:return: the matplotlib object
@@ -102,10 +102,10 @@ def plot_point(pos, marker="bs", label=None, text=None, ax=None, textargs=None,
102102
103103
- Multiple points can be marked if ``pos`` is a 2xn array or a list of
104104
coordinate pairs. In this case:
105-
- all points have the same label
106-
- label can include the format string {} which is susbstituted for the
105+
- all points have the same ``text`` label
106+
- ``text`` can include the format string {} which is susbstituted for the
107107
point index, starting at zero
108-
- label can be a tuple containing a format string followed by vectors
108+
- ``text`` can be a tuple containing a format string followed by vectors
109109
of shape(n). For example::
110110
111111
``("#{0} a={1:.1f}, b={2:.1f}", a, b)``
@@ -129,9 +129,6 @@ def plot_point(pos, marker="bs", label=None, text=None, ax=None, textargs=None,
129129
columns of ``p`` and label them all with successive elements of ``z``.
130130
"""
131131

132-
if text is not None:
133-
raise DeprecationWarning('use label not text')
134-
135132
if isinstance(pos, np.ndarray):
136133
if pos.ndim == 1:
137134
x = pos[0]
@@ -171,22 +168,22 @@ def plot_point(pos, marker="bs", label=None, text=None, ax=None, textargs=None,
171168
handles.append(plt.plot(x, y, m, **kwargs))
172169
else:
173170
handles.append(plt.plot(x, y, marker, **kwargs))
174-
if label is not None:
171+
if text is not None:
175172
try:
176173
xy = zip(x, y)
177174
except TypeError:
178175
xy = [(x, y)]
179-
if isinstance(label, str):
176+
if isinstance(text, str):
180177
# simple string, but might have format chars
181178
for i, (x, y) in enumerate(xy):
182-
handles.append(plt.text(x, y, " " + label.format(i), **textopts))
183-
elif isinstance(label, (tuple, list)):
179+
handles.append(plt.text(x, y, " " + text.format(i), **textopts))
180+
elif isinstance(text, (tuple, list)):
184181
for i, (x, y) in enumerate(xy):
185182
handles.append(
186183
plt.text(
187184
x,
188185
y,
189-
" " + label[0].format(i, *[d[i] for d in label[1:]]),
186+
" " + text[0].format(i, *[d[i] for d in text[1:]]),
190187
**textopts
191188
)
192189
)

0 commit comments

Comments
 (0)