Skip to content

Commit d99714f

Browse files
authored
Merge pull request matplotlib#12165 from dstansby/mlab-remove
Remove deprecated mlab code
2 parents 8ba6651 + ca54244 commit d99714f

File tree

8 files changed

+389
-2687
lines changed

8 files changed

+389
-2687
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
Removal of deprecated :mod:`matplotlib.mlab` code
2+
-------------------------------------------------
3+
4+
Lots of code inside the :mod:`matplotlib.mlab` module which was deprecated
5+
in Matplotlib 2.2 has been removed. See below for a list:
6+
7+
- ``mlab.exp_safe`` (use `numpy.exp` instead)
8+
- ``mlab.amap``
9+
- ``mlab.logspace`` (use `numpy.logspace` instead)
10+
- ``mlab.rms_flat``
11+
- ``mlab.l1norm`` (use ``numpy.linalg.norm(a, ord=1)`` instead)
12+
- ``mlab.l2norm`` (use ``numpy.linalg.norm(a, ord=2)`` instead)
13+
- ``mlab.norm_flat`` (use ``numpy.linalg.norm(a.flat, ord=2)`` instead)
14+
- ``mlab.frange`` (use `numpy.arange` instead)
15+
- ``mlab.identity`` (use `numpy.identity` instead)
16+
- ``mlab.base_repr``
17+
- ``mlab.binary_repr``
18+
- ``mlab.ispower2``
19+
- ``mlab.log2`` (use `numpy.log2` instead)
20+
- ``mlab.isvector``
21+
- ``mlab.movavg``
22+
- ``mlab.safe_isinf`` (use `numpy.isinf` instead)
23+
- ``mlab.safe_isnan`` (use `numpy.isnan` instead)
24+
- ``mlab.cohere_pairs`` (use `scipy.signal.coherence` instead)
25+
- ``mlab.entropy`` (use `scipy.stats.entropy` instead)
26+
- ``mlab.normpdf`` (use `scipy.stats.norm.pdf` instead)
27+
- ``mlab.find`` (use ``np.nonzero(np.ravel(condition))`` instead)
28+
- ``mlab.longest_contiguous_ones``
29+
- ``mlab.longest_ones``
30+
- ``mlab.PCA``
31+
- ``mlab.prctile`` (use `numpy.percentile` instead)
32+
- ``mlab.prctile_rank``
33+
- ``mlab.center_matrix``
34+
- ``mlab.rk4`` (use `scipy.integrate.ode` instead)
35+
- ``mlab.bivariate_normal``
36+
- ``mlab.get_xyz_where``
37+
- ``mlab.get_sparse_matrix``
38+
- ``mlab.dist`` (use `numpy.hypot` instead)
39+
- ``mlab.dist_point_to_segment``
40+
- ``mlab.griddata`` (use `scipy.interpolate.griddata`)
41+
- ``mlab.less_simple_linear_interpolation`` (use `numpy.interp`)
42+
- ``mlab.slopes``
43+
- ``mlab.stineman_interp``
44+
- ``mlab.segments_intersect``
45+
- ``mlab.fftsurr``
46+
- ``mlab.offset_line``
47+
- ``mlab.quad2cubic``
48+
- ``mlab.vector_lengths``
49+
- ``mlab.distances_along_curve``
50+
- ``mlab.path_length``
51+
- ``mlab.cross_from_above``
52+
- ``mlab.cross_from_below``
53+
- ``mlab.contiguous_regions`` (use `.cbook.contiguous_regions` instead)
54+
- ``mlab.is_closed_polygon``
55+
- ``mlab.poly_between``
56+
- ``mlab.poly_below``
57+
- ``mlab.inside_poly``
58+
- ``mlab.csv2rec``
59+
- ``mlab.rec2csv`` (use `numpy.recarray.tofile` instead)
60+
- ``mlab.rec2text`` (use `numpy.recarray.tofile` instead)
61+
- ``mlab.rec_summarize``
62+
- ``mlab.rec_join``
63+
- ``mlab.recs_join``
64+
- ``mlab.rec_groupby``
65+
- ``mlab.rec_keep_fields``
66+
- ``mlab.rec_drop_fields``
67+
- ``mlab.rec_append_fields``
68+
- ``mlab.csvformat_factory``
69+
- ``mlab.get_formatd``
70+
- ``mlab.FormatDatetime`` (use `datetime.datetime.strftime` instead)
71+
- ``mlab.FormatDate`` (use `datetime.date.strftime` instead)
72+
- ``mlab.FormatMillions``, ``mlab.FormatThousands``, ``mlab.FormatPercent``,
73+
``mlab.FormatBool``, ``mlab.FormatInt``, ``mlab.FormatFloat``,
74+
``mlab.FormatFormatStr``, ``mlab.FormatString``, ``mlab.FormatObj``
75+
- ``mlab.donothing_callback``
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
Removal of deprecated :mod:`matplotlib.pylab` code
2+
--------------------------------------------------
3+
4+
Lots of code inside the :mod:`matplotlib.mlab` module which was deprecated
5+
in Matplotlib 2.2 has been removed. This means the following functions are
6+
no longer available in the `matplotlib.pylab` module:
7+
8+
- ``amap``
9+
- ``base_repr``
10+
- ``binary_repr``
11+
- ``bivariate_normal``
12+
- ``center_matrix``
13+
- ``csv2rec`` (use `numpy.recarray.tofile` instead)
14+
- ``dist`` (use `numpy.hypot` instead)
15+
- ``dist_point_to_segment``
16+
- ``distances_along_curve``
17+
- ``entropy`` (use `scipy.stats.entropy` instead)
18+
- ``exp_safe`` (use `numpy.exp` instead)
19+
- ``fftsurr``
20+
- ``find`` (use ``np.nonzero(np.ravel(condition))`` instead)
21+
- ``frange`` (use `numpy.arange` instead)
22+
- ``get_sparse_matrix``
23+
- ``get_xyz_where``
24+
- ``griddata`` (use `scipy.interpolate.griddata` instead)
25+
- ``identity`` (use `numpy.identity` instead)
26+
- ``inside_poly``
27+
- ``is_closed_polygon``
28+
- ``ispower2``
29+
- ``isvector``
30+
- ``l1norm`` (use ``numpy.linalg.norm(a, ord=1)`` instead)
31+
- ``l2norm`` (use ``numpy.linalg.norm(a, ord=2)`` instead)
32+
- ``log2`` (use `numpy.log2` instead)
33+
- ``longest_contiguous_ones``
34+
- ``longest_ones``
35+
- ``movavg``
36+
- ``norm_flat`` (use ``numpy.linalg.norm(a.flat, ord=2)`` instead)
37+
- ``normpdf`` (use `scipy.stats.norm.pdf` instead)
38+
- ``path_length``
39+
- ``poly_below``
40+
- ``poly_between``
41+
- ``prctile`` (use `numpy.percentile` instead)
42+
- ``prctile_rank``
43+
- ``rec2csv`` (use `numpy.recarray.tofile` instead)
44+
- ``rec_append_fields``
45+
- ``rec_drop_fields``
46+
- ``rec_join``
47+
- ``rk4`` (use `scipy.integrate.ode` instead)
48+
- ``rms_flat``
49+
- ``segments_intersect``
50+
- ``slopes``
51+
- ``stineman_interp``
52+
- ``vector_lengths``

examples/event_handling/poly_editor.py

+28-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,34 @@
99
import numpy as np
1010
from matplotlib.lines import Line2D
1111
from matplotlib.artist import Artist
12-
from matplotlib.mlab import dist_point_to_segment
12+
13+
14+
def dist(x, y):
15+
"""
16+
Return the distance between two points.
17+
"""
18+
d = x - y
19+
return np.sqrt(np.dot(d, d))
20+
21+
22+
def dist_point_to_segment(p, s0, s1):
23+
"""
24+
Get the distance of a point to a segment.
25+
*p*, *s0*, *s1* are *xy* sequences
26+
This algorithm from
27+
http://geomalgorithms.com/a02-_lines.html
28+
"""
29+
v = s1 - s0
30+
w = p - s0
31+
c1 = np.dot(w, v)
32+
if c1 <= 0:
33+
return dist(p, s0)
34+
c2 = np.dot(v, v)
35+
if c2 <= c1:
36+
return dist(p, s1)
37+
b = c1 / c2
38+
pb = s0 + b * v
39+
return dist(p, pb)
1340

1441

1542
class PolygonInteractor(object):

0 commit comments

Comments
 (0)