From c76a337d74f57ef91a84ec28beca4b23e55e968d Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Fri, 22 Jun 2018 02:50:08 +0200 Subject: [PATCH] remove-pylab-references --- examples/user_interfaces/pylab_with_gtk_sgskip.py | 8 ++++---- lib/matplotlib/__init__.py | 4 ++-- lib/matplotlib/backends/backend_template.py | 6 +++--- lib/matplotlib/figure.py | 2 +- lib/matplotlib/mlab.py | 14 +++++++------- lib/matplotlib/pyplot.py | 2 +- lib/matplotlib/quiver.py | 4 ++-- lib/matplotlib/widgets.py | 15 +++++---------- lib/mpl_toolkits/axes_grid1/colorbar.py | 4 ++-- setup.py | 3 +-- 10 files changed, 28 insertions(+), 34 deletions(-) diff --git a/examples/user_interfaces/pylab_with_gtk_sgskip.py b/examples/user_interfaces/pylab_with_gtk_sgskip.py index 4308107afc76..093105f1bd46 100644 --- a/examples/user_interfaces/pylab_with_gtk_sgskip.py +++ b/examples/user_interfaces/pylab_with_gtk_sgskip.py @@ -1,9 +1,9 @@ """ -============== -Pylab With GTK -============== +=============== +Pyplot With GTK +=============== -An example of how to use pylab to manage your figure windows, but +An example of how to use pyplot to manage your figure windows, but modify the GUI by accessing the underlying gtk widgets """ import matplotlib diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index 6820021537a8..2e4ee4edb393 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -28,7 +28,7 @@ Modules include: :mod:`matplotlib.axes` - defines the :class:`~matplotlib.axes.Axes` class. Most pylab + defines the :class:`~matplotlib.axes.Axes` class. Most pyplot commands are wrappers for :class:`~matplotlib.axes.Axes` methods. The axes module is the highest level of OO access to the library. @@ -90,7 +90,7 @@ a function for setting the matplotlib backend. If used, this function must be called immediately after importing matplotlib for the first time. In particular, it must be called - **before** importing pylab (if pylab is imported). + **before** importing pyplot (if pyplot is imported). matplotlib was initially written by John D. Hunter (1968-2012) and is now developed and maintained by a host of others. diff --git a/lib/matplotlib/backends/backend_template.py b/lib/matplotlib/backends/backend_template.py index 384a69850230..65a782a66089 100644 --- a/lib/matplotlib/backends/backend_template.py +++ b/lib/matplotlib/backends/backend_template.py @@ -21,8 +21,8 @@ import matplotlib matplotlib.use('xxx') - from pylab import * - plot([1,2,3]) + import matplotlib.pyplot as plt + plt.plot([1,2,3]) show() matplotlib also supports external backends, so you can place you can @@ -175,7 +175,7 @@ def draw_if_interactive(): def show(block=None): """ For image backends - is not required - For GUI backends - show() is usually the last line of a pylab script and + For GUI backends - show() is usually the last line of a pyplot script and tells the backend that it is time to draw. In interactive mode, this may be a do nothing func. See the GTK backend for an example of how to handle interactive versus batch mode diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index 134e727fef97..8403ccf15a68 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -1892,7 +1892,7 @@ def colorbar(self, mappable, cax=None, ax=None, use_gridspec=True, **kw): """ Create a colorbar for a ScalarMappable instance, *mappable*. - Documentation for the pylab thin wrapper: + Documentation for the pyplot thin wrapper: %(colorbar_doc)s """ if ax is None: diff --git a/lib/matplotlib/mlab.py b/lib/matplotlib/mlab.py index cbb479ab359a..f857cc79fcc5 100644 --- a/lib/matplotlib/mlab.py +++ b/lib/matplotlib/mlab.py @@ -841,15 +841,15 @@ def _single_spectrum_helper(x, mode, Fs=None, window=None, pad_to=None, The function applied to each segment before fft-ing, designed to remove the mean or linear trend. Unlike in MATLAB, where the *detrend* parameter is a vector, in - matplotlib is it a function. The :mod:`~matplotlib.pylab` - module defines :func:`~matplotlib.pylab.detrend_none`, - :func:`~matplotlib.pylab.detrend_mean`, and - :func:`~matplotlib.pylab.detrend_linear`, but you can use + matplotlib is it a function. The :mod:`~matplotlib.mlab` + module defines :func:`~matplotlib.mlab.detrend_none`, + :func:`~matplotlib.mlab.detrend_mean`, and + :func:`~matplotlib.mlab.detrend_linear`, but you can use a custom function as well. You can also use a string to choose one of the functions. 'default', 'constant', and 'mean' call - :func:`~matplotlib.pylab.detrend_mean`. 'linear' calls - :func:`~matplotlib.pylab.detrend_linear`. 'none' calls - :func:`~matplotlib.pylab.detrend_none`. + :func:`~matplotlib.mlab.detrend_mean`. 'linear' calls + :func:`~matplotlib.mlab.detrend_linear`. 'none' calls + :func:`~matplotlib.mlab.detrend_none`. scale_by_freq : bool, optional Specifies whether the resulting density values should be scaled diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index 58df65f89ce6..b8fa2065d17b 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -2117,7 +2117,7 @@ def plotfile(fname, cols=(0,), plotfuncs=None, columns. *comments*, *skiprows*, *checkrows*, *delimiter*, and *names* - are all passed on to :func:`matplotlib.pylab.csv2rec` to + are all passed on to :func:`matplotlib.mlab.csv2rec` to load the data into a record array. If *newfig* is *True*, the plot always will be made in a new figure; diff --git a/lib/matplotlib/quiver.py b/lib/matplotlib/quiver.py index 65a34c0874cb..cc295a2a79b9 100644 --- a/lib/matplotlib/quiver.py +++ b/lib/matplotlib/quiver.py @@ -439,7 +439,7 @@ def __init__(self, ax, *args, """ The constructor takes one required argument, an Axes instance, followed by the args and kwargs described - by the following pylab interface documentation: + by the following pyplot interface documentation: %s """ self.ax = ax @@ -912,7 +912,7 @@ def __init__(self, ax, *args, """ The constructor takes one required argument, an Axes instance, followed by the args and kwargs described - by the following pylab interface documentation: + by the following pyplot interface documentation: %(barbs_doc)s """ self.sizes = sizes or dict() diff --git a/lib/matplotlib/widgets.py b/lib/matplotlib/widgets.py index 72ed42237b03..d78ee8f5e080 100644 --- a/lib/matplotlib/widgets.py +++ b/lib/matplotlib/widgets.py @@ -1332,18 +1332,13 @@ class MultiCursor(Widget): Example usage:: from matplotlib.widgets import MultiCursor - from pylab import figure, show, np + import matplotlib.pyplot as plt + import numpy as np + fig, (ax1, ax2) = plt.subplots(nrows=2, sharex=True) t = np.arange(0.0, 2.0, 0.01) - s1 = np.sin(2*np.pi*t) - s2 = np.sin(4*np.pi*t) - fig = figure() - ax1 = fig.add_subplot(211) - ax1.plot(t, s1) - - - ax2 = fig.add_subplot(212, sharex=ax1) - ax2.plot(t, s2) + ax1.plot(t, np.sin(2*np.pi*t)) + ax2.plot(t, np.sin(4*np.pi*t)) multi = MultiCursor(fig.canvas, (ax1, ax2), color='r', lw=1, horizOn=False, vertOn=True) diff --git a/lib/mpl_toolkits/axes_grid1/colorbar.py b/lib/mpl_toolkits/axes_grid1/colorbar.py index 6b33b57ad6d6..8683cca7c54c 100644 --- a/lib/mpl_toolkits/axes_grid1/colorbar.py +++ b/lib/mpl_toolkits/axes_grid1/colorbar.py @@ -295,7 +295,7 @@ class ColorbarBase(cm.ScalarMappable): Draw a colorbar in an existing axes. This is a base class for the :class:`Colorbar` class, which is the - basis for the :func:`~matplotlib.pyplot.colorbar` method and pylab + basis for the :func:`~matplotlib.pyplot.colorbar` method and pyplot function. It is also useful by itself for showing a colormap. If the *cmap* @@ -799,7 +799,7 @@ def colorbar(mappable, cax=None, ax=None, **kw): """ Create a colorbar for a ScalarMappable instance. - Documentation for the pylab thin wrapper: + Documentation for the pyplot thin wrapper: %s """ diff --git a/setup.py b/setup.py index 0f21795ff23b..7d23246f8647 100644 --- a/setup.py +++ b/setup.py @@ -255,8 +255,7 @@ def run(self): Matplotlib strives to produce publication quality 2D graphics for interactive graphing, scientific publishing, user interface development and web application servers targeting multiple user - interfaces and hardcopy output formats. There is a 'pylab' mode - which emulates MATLAB graphics. + interfaces and hardcopy output formats. """, license="BSD", packages=packages,