Skip to content

Commit f73f04c

Browse files
committed
Merge pull request #3185 from tacaswell/plot_surf_doc
DOC : added details about r/cstride in plot3d
2 parents 2ef9cf1 + c6f4168 commit f73f04c

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

+21-13
Original file line numberDiff line numberDiff line change
@@ -1533,12 +1533,17 @@ def plot_surface(self, X, Y, Z, *args, **kwargs):
15331533
but it also supports color mapping by supplying the *cmap*
15341534
argument.
15351535
1536+
The `rstride` and `cstride` kwargs set the stride used to
1537+
sample the input data to generate the graph. If 1k by 1k
1538+
arrays are passed in the default values for the strides will
1539+
result in a 100x100 grid being plotted.
1540+
15361541
============= ================================================
15371542
Argument Description
15381543
============= ================================================
15391544
*X*, *Y*, *Z* Data values as 2D arrays
1540-
*rstride* Array row stride (step size)
1541-
*cstride* Array column stride (step size)
1545+
*rstride* Array row stride (step size), defaults to 10
1546+
*cstride* Array column stride (step size), defaults to 10
15421547
*color* Color of the surface patches
15431548
*cmap* A colormap for the surface patches.
15441549
*facecolors* Face colors for the individual patches
@@ -1704,13 +1709,16 @@ def plot_wireframe(self, X, Y, Z, *args, **kwargs):
17041709
'''
17051710
Plot a 3D wireframe.
17061711
1712+
The `rstride` and `cstride` kwargs set the stride used to
1713+
sample the input data to generate the graph.
1714+
17071715
========== ================================================
17081716
Argument Description
17091717
========== ================================================
17101718
*X*, *Y*, Data values as 2D arrays
17111719
*Z*
1712-
*rstride* Array row stride (step size)
1713-
*cstride* Array column stride (step size)
1720+
*rstride* Array row stride (step size), defaults to 1
1721+
*cstride* Array column stride (step size), defaults to 1
17141722
========== ================================================
17151723
17161724
Keyword arguments are passed on to
@@ -2453,34 +2461,34 @@ def calc_arrow(u, v, w, angle=15):
24532461
"""
24542462
To calculate the arrow head. (u, v, w) should be unit vector.
24552463
"""
2456-
2464+
24572465
# this part figures out the axis of rotation to use
24582466

24592467
# use unit vector perpendicular to (u,v,w) when |w|=1, by default
2460-
x, y, z = 0, 1, 0
2468+
x, y, z = 0, 1, 0
24612469

2462-
# get the norm
2463-
norm = math.sqrt(v**2 + u**2)
2470+
# get the norm
2471+
norm = math.sqrt(v**2 + u**2)
24642472
# normalize it if it is safe
24652473
if norm > 0:
24662474
# get unit direction vector perpendicular to (u,v,w)
2467-
x, y = v/norm, -u/norm
2475+
x, y = v/norm, -u/norm
24682476

2469-
# this function takes an angle, and rotates the (u,v,w)
2477+
# this function takes an angle, and rotates the (u,v,w)
24702478
# angle degrees around (x,y,z)
24712479
def rotatefunction(angle):
2472-
ra = math.radians(angle)
2480+
ra = math.radians(angle)
24732481
c = math.cos(ra)
24742482
s = math.sin(ra)
24752483

24762484
# construct the rotation matrix
24772485
R = np.matrix([[c+(x**2)*(1-c), x*y*(1-c)-z*s, x*z*(1-c)+y*s],
24782486
[y*x*(1-c)+z*s, c+(y**2)*(1-c), y*z*(1-c)-x*s],
24792487
[z*x*(1-c)-y*s, z*y*(1-c)+x*s, c+(z**2)*(1-c)]])
2480-
2488+
24812489
# construct the column vector for (u,v,w)
24822490
line = np.matrix([[u],[v],[w]])
2483-
2491+
24842492
# use numpy to multiply them to get the rotated vector
24852493
rotatedline = R*line
24862494

0 commit comments

Comments
 (0)