pylab.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. """
  2. .. warning::
  3. Since heavily importing into the global namespace may result in unexpected
  4. behavior, the use of pylab is strongly discouraged. Use `matplotlib.pyplot`
  5. instead.
  6. `pylab` is a module that includes `matplotlib.pyplot`, `numpy`, `numpy.fft`,
  7. `numpy.linalg`, `numpy.random`, and some additional functions, all within
  8. a single namespace. Its original purpose was to mimic a MATLAB-like way
  9. of working by importing all functions into the global namespace. This is
  10. considered bad style nowadays.
  11. """
  12. from matplotlib.cbook import flatten, silent_list
  13. import matplotlib as mpl
  14. from matplotlib.dates import (
  15. date2num, num2date, datestr2num, drange, epoch2num,
  16. num2epoch, mx2num, DateFormatter, IndexDateFormatter, DateLocator,
  17. RRuleLocator, YearLocator, MonthLocator, WeekdayLocator, DayLocator,
  18. HourLocator, MinuteLocator, SecondLocator, rrule, MO, TU, WE, TH, FR,
  19. SA, SU, YEARLY, MONTHLY, WEEKLY, DAILY, HOURLY, MINUTELY, SECONDLY,
  20. relativedelta)
  21. # bring all the symbols in so folks can import them from
  22. # pylab in one fell swoop
  23. ## We are still importing too many things from mlab; more cleanup is needed.
  24. from matplotlib.mlab import (
  25. detrend, detrend_linear, detrend_mean, detrend_none, window_hanning,
  26. window_none)
  27. from matplotlib import cbook, mlab, pyplot as plt
  28. from matplotlib.pyplot import *
  29. from numpy import *
  30. from numpy.fft import *
  31. from numpy.random import *
  32. from numpy.linalg import *
  33. import numpy as np
  34. import numpy.ma as ma
  35. # don't let numpy's datetime hide stdlib
  36. import datetime
  37. # This is needed, or bytes will be numpy.random.bytes from
  38. # "from numpy.random import *" above
  39. bytes = __import__("builtins").bytes