68 lines
2.3 KiB
Python
68 lines
2.3 KiB
Python
"""
|
|
`pylab` is a historic interface and its use is strongly discouraged. The equivalent
|
|
replacement is `matplotlib.pyplot`. See :ref:`api_interfaces` for a full overview
|
|
of Matplotlib interfaces.
|
|
|
|
`pylab` was designed to support a MATLAB-like way of working with all plotting related
|
|
functions directly available in the global namespace. This was achieved through a
|
|
wildcard import (``from pylab import *``).
|
|
|
|
.. warning::
|
|
The use of `pylab` is discouraged for the following reasons:
|
|
|
|
``from pylab import *`` imports all the functions from `matplotlib.pyplot`, `numpy`,
|
|
`numpy.fft`, `numpy.linalg`, and `numpy.random`, and some additional functions into
|
|
the global namespace.
|
|
|
|
Such a pattern is considered bad practice in modern python, as it clutters the global
|
|
namespace. Even more severely, in the case of `pylab`, this will overwrite some
|
|
builtin functions (e.g. the builtin `sum` will be replaced by `numpy.sum`), which
|
|
can lead to unexpected behavior.
|
|
|
|
"""
|
|
|
|
from matplotlib.cbook import flatten, silent_list
|
|
|
|
import matplotlib as mpl
|
|
|
|
from matplotlib.dates import (
|
|
date2num, num2date, datestr2num, drange, DateFormatter, DateLocator,
|
|
RRuleLocator, YearLocator, MonthLocator, WeekdayLocator, DayLocator,
|
|
HourLocator, MinuteLocator, SecondLocator, rrule, MO, TU, WE, TH, FR,
|
|
SA, SU, YEARLY, MONTHLY, WEEKLY, DAILY, HOURLY, MINUTELY, SECONDLY,
|
|
relativedelta)
|
|
|
|
# bring all the symbols in so folks can import them from
|
|
# pylab in one fell swoop
|
|
|
|
## We are still importing too many things from mlab; more cleanup is needed.
|
|
|
|
from matplotlib.mlab import (
|
|
detrend, detrend_linear, detrend_mean, detrend_none, window_hanning,
|
|
window_none)
|
|
|
|
from matplotlib import cbook, mlab, pyplot as plt
|
|
from matplotlib.pyplot import *
|
|
|
|
from numpy import *
|
|
from numpy.fft import *
|
|
from numpy.random import *
|
|
from numpy.linalg import *
|
|
|
|
import numpy as np
|
|
import numpy.ma as ma
|
|
|
|
# don't let numpy's datetime hide stdlib
|
|
import datetime
|
|
|
|
# This is needed, or bytes will be numpy.random.bytes from
|
|
# "from numpy.random import *" above
|
|
bytes = __import__("builtins").bytes
|
|
# We also don't want the numpy version of these functions
|
|
abs = __import__("builtins").abs
|
|
bool = __import__("builtins").bool
|
|
max = __import__("builtins").max
|
|
min = __import__("builtins").min
|
|
pow = __import__("builtins").pow
|
|
round = __import__("builtins").round
|