Skip to content

remove more pylab references #11481

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion lib/matplotlib/backends/backend_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
matplotlib.use('xxx')
import matplotlib.pyplot as plt
plt.plot([1,2,3])
show()
plt.show()

matplotlib also supports external backends, so you can place you can
use any module in your PYTHONPATH with the syntax::
Expand Down
14 changes: 8 additions & 6 deletions lib/matplotlib/mlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -4000,13 +4000,15 @@ def offset_line(y, yerr):
* A tuple of length 2. In this case, yerr[0] is the error below *y* and
yerr[1] is error above *y*. For example::

from pylab import *
x = linspace(0, 2*pi, num=100, endpoint=True)
y = sin(x)
import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(0, 2*np.pi, num=100, endpoint=True)
y = np.sin(x)
y_minus, y_plus = mlab.offset_line(y, 0.1)
plot(x, y)
fill_between(x, ym, y2=yp)
show()
plt.plot(x, y)
plt.fill_between(x, y_minus, y2=y_plus)
plt.show()

"""
if cbook.is_numlike(yerr) or (cbook.iterable(yerr) and
Expand Down
64 changes: 32 additions & 32 deletions lib/matplotlib/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1342,7 +1342,7 @@ class MultiCursor(Widget):

multi = MultiCursor(fig.canvas, (ax1, ax2), color='r', lw=1,
horizOn=False, vertOn=True)
show()
plt.show()

"""
def __init__(self, canvas, axes, useblit=True, horizOn=False, vertOn=True,
Expand Down Expand Up @@ -1954,33 +1954,33 @@ class RectangleSelector(_SelectorWidget):

Example usage::

from matplotlib.widgets import RectangleSelector
from pylab import *
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import RectangleSelector

def onselect(eclick, erelease):
'eclick and erelease are matplotlib events at press and release'
print(' startposition : (%f, %f)' % (eclick.xdata, eclick.ydata))
print(' endposition : (%f, %f)' % (erelease.xdata, erelease.ydata))
print(' used button : ', eclick.button)
"eclick and erelease are matplotlib events at press and release."
print('startposition: (%f, %f)' % (eclick.xdata, eclick.ydata))
print('endposition : (%f, %f)' % (erelease.xdata, erelease.ydata))
print('used button : ', eclick.button)

def toggle_selector(event):
print(' Key pressed.')
print('Key pressed.')
if event.key in ['Q', 'q'] and toggle_selector.RS.active:
print(' RectangleSelector deactivated.')
print('RectangleSelector deactivated.')
toggle_selector.RS.set_active(False)
if event.key in ['A', 'a'] and not toggle_selector.RS.active:
print(' RectangleSelector activated.')
print('RectangleSelector activated.')
toggle_selector.RS.set_active(True)

x = arange(100)/(99.0)
y = sin(x)
fig = figure
ax = subplot(111)
ax.plot(x,y)
x = np.arange(100.) / 99
y = np.sin(x)
fig, ax = plt.subplots()
ax.plot(x, y)

toggle_selector.RS = RectangleSelector(ax, onselect, drawtype='line')
connect('key_press_event', toggle_selector)
show()
fig.canvas.connect('key_press_event', toggle_selector)
plt.show()
"""

_shape_klass = Rectangle
Expand Down Expand Up @@ -2385,33 +2385,33 @@ class EllipseSelector(RectangleSelector):

Example usage::

from matplotlib.widgets import EllipseSelector
from pylab import *
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import EllipseSelector

def onselect(eclick, erelease):
'eclick and erelease are matplotlib events at press and release'
print(' startposition : (%f, %f)' % (eclick.xdata, eclick.ydata))
print(' endposition : (%f, %f)' % (erelease.xdata, erelease.ydata))
print(' used button : ', eclick.button)
"eclick and erelease are matplotlib events at press and release."
print('startposition: (%f, %f)' % (eclick.xdata, eclick.ydata))
print('endposition : (%f, %f)' % (erelease.xdata, erelease.ydata))
print('used button : ', eclick.button)

def toggle_selector(event):
print(' Key pressed.')
if event.key in ['Q', 'q'] and toggle_selector.ES.active:
print(' EllipseSelector deactivated.')
print('EllipseSelector deactivated.')
toggle_selector.RS.set_active(False)
if event.key in ['A', 'a'] and not toggle_selector.ES.active:
print(' EllipseSelector activated.')
print('EllipseSelector activated.')
toggle_selector.ES.set_active(True)

x = arange(100)/(99.0)
y = sin(x)
fig = figure
ax = subplot(111)
ax.plot(x,y)
x = np.arange(100.) / 99
y = np.sin(x)
fig, ax = plt.subplots()
ax.plot(x, y)

toggle_selector.ES = EllipseSelector(ax, onselect, drawtype='line')
connect('key_press_event', toggle_selector)
show()
fig.canvas.connect('key_press_event', toggle_selector)
plt.show()
"""
_shape_klass = Ellipse

Expand Down
8 changes: 4 additions & 4 deletions tutorials/intermediate/artists.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ class in the matplotlib API, and the one you will be working with most
# If you are working interactively at the python shell, a handy way to
# inspect the ``Artist`` properties is to use the
# :func:`matplotlib.artist.getp` function (simply
# :func:`~matplotlib.pylab.getp` in pylab), which lists the properties
# :func:`~matplotlib.pyplot.getp` in pyplot), which lists the properties
# and their values. This works for classes derived from ``Artist`` as
# well, e.g., ``Figure`` and ``Rectangle``. Here are the ``Figure`` rectangle
# properties mentioned above:
Expand Down Expand Up @@ -556,9 +556,9 @@ class in the matplotlib API, and the one you will be working with most
# the ticks are placed and how they are represented as strings.
#
# Each ``Axis`` object contains a :attr:`~matplotlib.axis.Axis.label` attribute
# (this is what :mod:`~matplotlib.pylab` modifies in calls to
# :func:`~matplotlib.pylab.xlabel` and :func:`~matplotlib.pylab.ylabel`) as well
# as a list of major and minor ticks. The ticks are
# (this is what :mod:`~matplotlib.pyplot` modifies in calls to
# :func:`~matplotlib.pyplot.xlabel` and :func:`~matplotlib.pyplot.ylabel`) as
# well as a list of major and minor ticks. The ticks are
# :class:`~matplotlib.axis.XTick` and :class:`~matplotlib.axis.YTick` instances,
# which contain the actual line and text primitives that render the ticks and
# ticklabels. Because the ticks are dynamically created as needed (e.g., when
Expand Down
3 changes: 2 additions & 1 deletion tutorials/introductory/usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@
# :mod:`pylab` is a convenience module that bulk imports
# :mod:`matplotlib.pyplot` (for plotting) and :mod:`numpy`
# (for mathematics and working with arrays) in a single name space.
# Although many examples use :mod:`pylab`, it is no longer recommended.
# pylab is deprecated and its use is strongly discouraged because
# of namespace pollution. Use pyplot instead.
#
# For non-interactive plotting it is suggested
# to use pyplot to create the figures and then the OO interface for
Expand Down