Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Replace path_length in contour
  • Loading branch information
dstansby committed Sep 16, 2017
commit b4e339af4cc20fa9178619697c947f4b9b08b094
8 changes: 5 additions & 3 deletions lib/matplotlib/contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ def calc_label_rot_and_inline(self, slc, ind, lw, lc=None, spacing=5):
not empty (lc defaults to the empty list if None). *spacing*
is the space around the label in pixels to leave empty.

Do both of these tasks at once to avoid calling mlab.path_length
Do both of these tasks at once to avoid calculating path lengths
multiple times, which is relatively costly.

The method used here involves calculating the path length
Expand All @@ -400,8 +400,10 @@ def calc_label_rot_and_inline(self, slc, ind, lw, lc=None, spacing=5):

ind = 0

# Path length in pixel space
pl = mlab.path_length(slc)
# Calculate path lengths
pl = np.zeros(slc.shape[0], dtype=float)
dx = np.diff(slc, axis=0)
pl[1:] = np.cumsum(np.hypot(dx[:, 0], dx[:, 1]))
pl = pl - pl[ind]

# Use linear interpolation to get points around label
Expand Down
3 changes: 3 additions & 0 deletions lib/matplotlib/mlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -3911,6 +3911,7 @@ def cross_from_above(x, threshold):
##################################################
# Vector and path length geometry calculations
##################################################
@cbook.deprecated('2.2')
def vector_lengths(X, P=2., axis=None):
"""
Finds the length of a set of vectors in *n* dimensions. This is
Expand All @@ -3925,6 +3926,7 @@ def vector_lengths(X, P=2., axis=None):
return (np.sum(X**(P), axis=axis))**(1./P)


@cbook.deprecated('2.2')
def distances_along_curve(X):
"""
Computes the distance between a set of successive points in *N* dimensions.
Expand All @@ -3937,6 +3939,7 @@ def distances_along_curve(X):
return vector_lengths(X, axis=1)


@cbook.deprecated('2.2')
def path_length(X):
"""
Computes the distance travelled along a polygonal curve in *N* dimensions.
Expand Down