Skip to content

Issue # 11526 - keyword arguments for quiver/barb #11798

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions lib/matplotlib/quiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,10 +381,17 @@ def contains(self, mouseevent):
# This is a helper function that parses out the various combination of
# arguments for doing colored vector plots. Pulling it out here
# allows both Quiver and Barbs to use it
def _parse_args(*args):
def _parse_args(*args, **kwargs):
X, Y, U, V, C = [None] * 5
args = list(args)

if len(args) == 0:
if kwargs.get("X") != None: args.append(kwargs.pop("X"))
if kwargs.get("Y") != None: args.append(kwargs.pop("Y"))
if kwargs.get("U") != None: args.append(kwargs.pop("U"))
if kwargs.get("V") != None: args.append(kwargs.pop("V"))
if kwargs.get("C") != None: args.append(kwargs.pop("C"))

# The use of atleast_1d allows for handling scalar arguments while also
# keeping masked arrays
if len(args) == 3 or len(args) == 5:
Expand All @@ -402,7 +409,7 @@ def _parse_args(*args):
else:
indexgrid = np.meshgrid(np.arange(nc), np.arange(nr))
X, Y = [np.ravel(a) for a in indexgrid]
return X, Y, U, V, C
return X, Y, U, V, C, args, kwargs


def _check_consistent_shapes(*arrays):
Expand Down Expand Up @@ -443,7 +450,9 @@ def __init__(self, ax, *args,
%s
"""
self.ax = ax
X, Y, U, V, C = _parse_args(*args)
# If **kw is used for input then output a new set of *args, **kw
# once it has been parsed out. See _parse_args
X, Y, U, V, C, args, kw = _parse_args(*args, **kw)
self.X = X
self.Y = Y
self.XY = np.column_stack((X, Y))
Expand Down Expand Up @@ -950,7 +959,9 @@ def __init__(self, ax, *args,
kw['linewidth'] = 1

# Parse out the data arrays from the various configurations supported
x, y, u, v, c = _parse_args(*args)
# If **kw is used for input then output a new set of *args, **kw
# once it has been parsed out. See _parse_args
x, y, u, v, c, args, kw = _parse_args(*args, **kw)
self.x = x
self.y = y
xy = np.column_stack((x, y))
Expand Down