Description
Bug summary
plt.barbs is a command that cannot be passed in a c parameter by parameter name, but can be passed in the form of a positional parameter
Code for reproduction
plt.barbs(X,Y,uwind,vwind,c = wind_speed.T,
length = 5,
linewidth = 0.5,
# pivot = 'middle',
# zorder=1,
barb_increments=dict(half=2, full=4, flag=20),
sizes = dict(spacing = 0.15,height = 0.5,width = 0.12),cmap = Dbs_map,norm = norm_Dbs,
)
Actual outcome
AttributeError Traceback (most recent call last)
Cell In[182], line 22
20 fontticks = fm.FontProperties(size = 22 ,weight = 'bold', family = 'Times New Roman')
21 fontlabel = fm.FontProperties(weight = 'bold', family = 'Times New Roman',size = 22)
---> 22 plt.barbs(X,Y,uwind,vwind,c = wind_speed.T,
23 length = 5,
24 linewidth = 0.5,
25 # pivot = 'middle',
26 # zorder=1,
27 barb_increments=dict(half=2, full=4, flag=20),
28 sizes = dict(spacing = 0.15,height = 0.5,width = 0.12),cmap = Dbs_map,norm = norm_Dbs,
29 )#
31 # 设置x轴标签和刻度
32 x_ticks = [times[0]] + [times[int((len(times) - 1) * i / 5)] for i in range(1, 6)]
File d:\codetools\anaconda\home\envs\py38\lib\site-packages\matplotlib\pyplot.py:2447, in barbs(data, *args, **kwargs)
2445 @_copy_docstring_and_deprecators(Axes.barbs)
2446 def barbs(*args, data=None, **kwargs):
-> 2447 return gca().barbs(
2448 *args, **({"data": data} if data is not None else {}),
2449 **kwargs)
File d:\codetools\anaconda\home\envs\py38\lib\site-packages\matplotlib_init_.py:1475, in _preprocess_data..inner(ax, data, *args, **kwargs)
1472 @functools.wraps(func)
1473 def inner(ax, *args, data=None, **kwargs):
1474 if data is None:
-> 1475 return func(ax, *map(sanitize_sequence, args), **kwargs)
1477 bound = new_sig.bind(ax, *args, **kwargs)
1478 auto_label = (bound.arguments.get(label_namer)
1479 or bound.kwargs.get(label_namer))
File d:\codetools\anaconda\home\envs\py38\lib\site-packages\matplotlib\axes_axes.py:5173, in Axes.barbs(self, *args, **kwargs)
5171 # Make sure units are handled for x and y values
5172 args = self._quiver_units(args, kwargs)
-> 5173 b = mquiver.Barbs(self, *args, **kwargs)
5174 self.add_collection(b, autolim=True)
5175 self._request_autoscale_view()
File d:\codetools\anaconda\home\envs\py38\lib\site-packages\matplotlib\quiver.py:937, in Barbs.init(self, ax, pivot, length, barbcolor, flagcolor, sizes, fill_empty, barb_increments, rounding, flip_barb, *args, **kwargs)
935 # Make a collection
936 barb_size = self._length ** 2 / 4 # Empirically determined
--> 937 super().init(
938 [], (barb_size,), offsets=xy, offset_transform=transform, **kwargs)
939 self.set_transform(transforms.IdentityTransform())
941 self.set_UVC(u, v, c)
File d:\codetools\anaconda\home\envs\py38\lib\site-packages\matplotlib_api\deprecation.py:454, in make_keyword_only..wrapper(*args, **kwargs)
448 if len(args) > name_idx:
449 warn_deprecated(
450 since, message="Passing the %(name)s %(obj_type)s "
451 "positionally is deprecated since Matplotlib %(since)s; the "
452 "parameter will become keyword-only %(removal)s.",
453 name=name, obj_type=f"parameter of {func.name}()")
--> 454 return func(*args, **kwargs)
File d:\codetools\anaconda\home\envs\py38\lib\site-packages\matplotlib\collections.py:1170, in PolyCollection.init(self, verts, sizes, closed, **kwargs)
1149 @_api.make_keyword_only("3.6", name="closed")
1150 def init(self, verts, sizes=None, closed=True, **kwargs):
1151 """
1152 Parameters
1153 ----------
(...)
1168 Forwarded to .Collection
.
1169 """
-> 1170 super().init(**kwargs)
1171 self.set_sizes(sizes)
1172 self.set_verts(verts, closed)
File d:\codetools\anaconda\home\envs\py38\lib\site-packages\matplotlib_api\deprecation.py:454, in make_keyword_only..wrapper(*args, **kwargs)
448 if len(args) > name_idx:
449 warn_deprecated(
450 since, message="Passing the %(name)s %(obj_type)s "
451 "positionally is deprecated since Matplotlib %(since)s; the "
452 "parameter will become keyword-only %(removal)s.",
453 name=name, obj_type=f"parameter of {func.name}()")
--> 454 return func(*args, **kwargs)
File d:\codetools\anaconda\home\envs\py38\lib\site-packages\matplotlib\collections.py:201, in Collection.init(self, edgecolors, facecolors, linewidths, linestyles, capstyle, joinstyle, antialiaseds, offsets, offset_transform, norm, cmap, pickradius, hatch, urls, zorder, **kwargs)
198 self._offset_transform = offset_transform
200 self._path_effects = None
--> 201 self._internal_update(kwargs)
202 self._paths = None
File d:\codetools\anaconda\home\envs\py38\lib\site-packages\matplotlib\artist.py:1223, in Artist._internal_update(self, kwargs)
1216 def _internal_update(self, kwargs):
1217 """
1218 Update artist properties without prenormalizing them, but generating
1219 errors as if calling set
.
1220
1221 The lack of prenormalization is to maintain backcompatibility.
1222 """
-> 1223 return self._update_props(
1224 kwargs, "{cls.name}.set() got an unexpected keyword argument "
1225 "{prop_name!r}")
File d:\codetools\anaconda\home\envs\py38\lib\site-packages\matplotlib\artist.py:1197, in Artist.update_props(self, props, errfmt)
1195 func = getattr(self, f"set{k}", None)
1196 if not callable(func):
-> 1197 raise AttributeError(
1198 errfmt.format(cls=type(self), prop_name=k))
1199 ret.append(func(v))
1200 if ret:
AttributeError: Barbs.set() got an unexpected keyword argument 'c'
Expected outcome
It should be possible to pass in data by parameter name
Additional information
No response
Operating system
Windows
Matplotlib Version
3.7.2
Matplotlib Backend
No response
Python version
3.8.16
Jupyter version
No response
Installation
None