Skip to content

Commit ee41a0c

Browse files
committed
Merge pull request #2851 from WeatherGod/mplot3d/fixtri
Fix positional/kwarg handling of the Z argument
2 parents f4217db + 7ef9a89 commit ee41a0c

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

+21-12
Original file line numberDiff line numberDiff line change
@@ -1827,12 +1827,17 @@ def plot_trisurf(self, *args, **kwargs):
18271827
lightsource = kwargs.pop('lightsource', None)
18281828

18291829
tri, args, kwargs = Triangulation.get_from_args_and_kwargs(*args, **kwargs)
1830-
z = np.asarray(args[0])
1830+
if 'Z' in kwargs:
1831+
z = np.asarray(kwargs.pop('Z'))
1832+
else:
1833+
z = np.asarray(args[0])
1834+
# We do this so Z doesn't get passed as an arg to PolyCollection
1835+
args = args[1:]
18311836

18321837
triangles = tri.get_masked_triangles()
1833-
xt = tri.x[triangles][...,np.newaxis]
1834-
yt = tri.y[triangles][...,np.newaxis]
1835-
zt = np.array(z)[triangles][...,np.newaxis]
1838+
xt = tri.x[triangles][..., np.newaxis]
1839+
yt = tri.y[triangles][..., np.newaxis]
1840+
zt = z[triangles][..., np.newaxis]
18361841

18371842
verts = np.concatenate((xt, yt, zt), axis=2)
18381843

@@ -2024,10 +2029,12 @@ def tricontour(self, *args, **kwargs):
20242029
*args, **kwargs)
20252030
X = tri.x
20262031
Y = tri.y
2027-
Z = args[0]
2028-
2029-
# We do this so Z doesn't get passed as an arg to Axes.tricontour
2030-
args = args[1:]
2032+
if 'Z' in kwargs:
2033+
Z = kwargs.pop('Z')
2034+
else:
2035+
Z = args[0]
2036+
# We do this so Z doesn't get passed as an arg to Axes.tricontour
2037+
args = args[1:]
20312038

20322039
jX, jY, jZ = art3d.rotate_axes(X, Y, Z, zdir)
20332040
tri = Triangulation(jX, jY, tri.triangles, tri.mask)
@@ -2109,10 +2116,12 @@ def tricontourf(self, *args, **kwargs):
21092116
*args, **kwargs)
21102117
X = tri.x
21112118
Y = tri.y
2112-
Z = args[0]
2113-
2114-
# We do this so Z doesn't get passed as an arg to Axes.tricontour
2115-
args = args[1:]
2119+
if 'Z' in kwargs:
2120+
Z = kwargs.pop('Z')
2121+
else:
2122+
Z = args[0]
2123+
# We do this so Z doesn't get passed as an arg to Axes.tricontourf
2124+
args = args[1:]
21162125

21172126
jX, jY, jZ = art3d.rotate_axes(X, Y, Z, zdir)
21182127
tri = Triangulation(jX, jY, tri.triangles, tri.mask)

0 commit comments

Comments
 (0)