Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c971b92

Browse filesBrowse files
author
y1thof
committed
remove more pylab references
1 parent f3e03d2 commit c971b92
Copy full SHA for c971b92

File tree

Expand file treeCollapse file tree

5 files changed

+47
-44
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+47
-44
lines changed

‎lib/matplotlib/backends/backend_template.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_template.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
matplotlib.use('xxx')
2424
import matplotlib.pyplot as plt
2525
plt.plot([1,2,3])
26-
show()
26+
plt.show()
2727
2828
matplotlib also supports external backends, so you can place you can
2929
use any module in your PYTHONPATH with the syntax::

‎lib/matplotlib/mlab.py

Copy file name to clipboardExpand all lines: lib/matplotlib/mlab.py
+8-6Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4000,13 +4000,15 @@ def offset_line(y, yerr):
40004000
* A tuple of length 2. In this case, yerr[0] is the error below *y* and
40014001
yerr[1] is error above *y*. For example::
40024002
4003-
from pylab import *
4004-
x = linspace(0, 2*pi, num=100, endpoint=True)
4005-
y = sin(x)
4003+
import numpy as np
4004+
import matplotlib.pyplot as plt
4005+
4006+
x = np.linspace(0, 2*np.pi, num=100, endpoint=True)
4007+
y = np.sin(x)
40064008
y_minus, y_plus = mlab.offset_line(y, 0.1)
4007-
plot(x, y)
4008-
fill_between(x, ym, y2=yp)
4009-
show()
4009+
plt.plot(x, y)
4010+
plt.fill_between(x, y_minus, y2=y_plus)
4011+
plt.show()
40104012
40114013
"""
40124014
if cbook.is_numlike(yerr) or (cbook.iterable(yerr) and

‎lib/matplotlib/widgets.py

Copy file name to clipboardExpand all lines: lib/matplotlib/widgets.py
+32-32Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,7 +1342,7 @@ class MultiCursor(Widget):
13421342
13431343
multi = MultiCursor(fig.canvas, (ax1, ax2), color='r', lw=1,
13441344
horizOn=False, vertOn=True)
1345-
show()
1345+
plt.show()
13461346
13471347
"""
13481348
def __init__(self, canvas, axes, useblit=True, horizOn=False, vertOn=True,
@@ -1954,33 +1954,33 @@ class RectangleSelector(_SelectorWidget):
19541954
19551955
Example usage::
19561956
1957-
from matplotlib.widgets import RectangleSelector
1958-
from pylab import *
1957+
import numpy as np
1958+
import matplotlib.pyplot as plt
1959+
from matplotlib.widgets import RectangleSelector
19591960
19601961
def onselect(eclick, erelease):
1961-
'eclick and erelease are matplotlib events at press and release'
1962-
print(' startposition : (%f, %f)' % (eclick.xdata, eclick.ydata))
1963-
print(' endposition : (%f, %f)' % (erelease.xdata, erelease.ydata))
1964-
print(' used button : ', eclick.button)
1962+
"eclick and erelease are matplotlib events at press and release."
1963+
print('startposition: (%f, %f)' % (eclick.xdata, eclick.ydata))
1964+
print('endposition : (%f, %f)' % (erelease.xdata, erelease.ydata))
1965+
print('used button : ', eclick.button)
19651966
19661967
def toggle_selector(event):
1967-
print(' Key pressed.')
1968+
print('Key pressed.')
19681969
if event.key in ['Q', 'q'] and toggle_selector.RS.active:
1969-
print(' RectangleSelector deactivated.')
1970+
print('RectangleSelector deactivated.')
19701971
toggle_selector.RS.set_active(False)
19711972
if event.key in ['A', 'a'] and not toggle_selector.RS.active:
1972-
print(' RectangleSelector activated.')
1973+
print('RectangleSelector activated.')
19731974
toggle_selector.RS.set_active(True)
19741975
1975-
x = arange(100)/(99.0)
1976-
y = sin(x)
1977-
fig = figure
1978-
ax = subplot(111)
1979-
ax.plot(x,y)
1976+
x = np.arange(100.) / 99
1977+
y = np.sin(x)
1978+
fig, ax = plt.subplots()
1979+
ax.plot(x, y)
19801980
19811981
toggle_selector.RS = RectangleSelector(ax, onselect, drawtype='line')
1982-
connect('key_press_event', toggle_selector)
1983-
show()
1982+
fig.canvas.connect('key_press_event', toggle_selector)
1983+
plt.show()
19841984
"""
19851985

19861986
_shape_klass = Rectangle
@@ -2385,33 +2385,33 @@ class EllipseSelector(RectangleSelector):
23852385
23862386
Example usage::
23872387
2388-
from matplotlib.widgets import EllipseSelector
2389-
from pylab import *
2388+
import numpy as np
2389+
import matplotlib.pyplot as plt
2390+
from matplotlib.widgets import EllipseSelector
23902391
23912392
def onselect(eclick, erelease):
2392-
'eclick and erelease are matplotlib events at press and release'
2393-
print(' startposition : (%f, %f)' % (eclick.xdata, eclick.ydata))
2394-
print(' endposition : (%f, %f)' % (erelease.xdata, erelease.ydata))
2395-
print(' used button : ', eclick.button)
2393+
"eclick and erelease are matplotlib events at press and release."
2394+
print('startposition: (%f, %f)' % (eclick.xdata, eclick.ydata))
2395+
print('endposition : (%f, %f)' % (erelease.xdata, erelease.ydata))
2396+
print('used button : ', eclick.button)
23962397
23972398
def toggle_selector(event):
23982399
print(' Key pressed.')
23992400
if event.key in ['Q', 'q'] and toggle_selector.ES.active:
2400-
print(' EllipseSelector deactivated.')
2401+
print('EllipseSelector deactivated.')
24012402
toggle_selector.RS.set_active(False)
24022403
if event.key in ['A', 'a'] and not toggle_selector.ES.active:
2403-
print(' EllipseSelector activated.')
2404+
print('EllipseSelector activated.')
24042405
toggle_selector.ES.set_active(True)
24052406
2406-
x = arange(100)/(99.0)
2407-
y = sin(x)
2408-
fig = figure
2409-
ax = subplot(111)
2410-
ax.plot(x,y)
2407+
x = np.arange(100.) / 99
2408+
y = np.sin(x)
2409+
fig, ax = plt.subplots()
2410+
ax.plot(x, y)
24112411
24122412
toggle_selector.ES = EllipseSelector(ax, onselect, drawtype='line')
2413-
connect('key_press_event', toggle_selector)
2414-
show()
2413+
fig.canvas.connect('key_press_event', toggle_selector)
2414+
plt.show()
24152415
"""
24162416
_shape_klass = Ellipse
24172417

‎tutorials/intermediate/artists.py

Copy file name to clipboardExpand all lines: tutorials/intermediate/artists.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ class in the matplotlib API, and the one you will be working with most
218218
# If you are working interactively at the python shell, a handy way to
219219
# inspect the ``Artist`` properties is to use the
220220
# :func:`matplotlib.artist.getp` function (simply
221-
# :func:`~matplotlib.pylab.getp` in pylab), which lists the properties
221+
# :func:`~matplotlib.pyplot.getp` in pyplot), which lists the properties
222222
# and their values. This works for classes derived from ``Artist`` as
223223
# well, e.g., ``Figure`` and ``Rectangle``. Here are the ``Figure`` rectangle
224224
# properties mentioned above:
@@ -556,9 +556,9 @@ class in the matplotlib API, and the one you will be working with most
556556
# the ticks are placed and how they are represented as strings.
557557
#
558558
# Each ``Axis`` object contains a :attr:`~matplotlib.axis.Axis.label` attribute
559-
# (this is what :mod:`~matplotlib.pylab` modifies in calls to
560-
# :func:`~matplotlib.pylab.xlabel` and :func:`~matplotlib.pylab.ylabel`) as well
561-
# as a list of major and minor ticks. The ticks are
559+
# (this is what :mod:`~matplotlib.pyplot` modifies in calls to
560+
# :func:`~matplotlib.pyplot.xlabel` and :func:`~matplotlib.pyplot.ylabel`) as
561+
# well as a list of major and minor ticks. The ticks are
562562
# :class:`~matplotlib.axis.XTick` and :class:`~matplotlib.axis.YTick` instances,
563563
# which contain the actual line and text primitives that render the ticks and
564564
# ticklabels. Because the ticks are dynamically created as needed (e.g., when

‎tutorials/introductory/usage.py

Copy file name to clipboardExpand all lines: tutorials/introductory/usage.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@
184184
# :mod:`pylab` is a convenience module that bulk imports
185185
# :mod:`matplotlib.pyplot` (for plotting) and :mod:`numpy`
186186
# (for mathematics and working with arrays) in a single name space.
187-
# Although many examples use :mod:`pylab`, it is no longer recommended.
187+
# pylab is deprecated and its use is strongly discouraged because
188+
# of namespace pollution. Use pyplot instead.
188189
#
189190
# For non-interactive plotting it is suggested
190191
# to use pyplot to create the figures and then the OO interface for

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.