title: What is the preferred way to import pylab at a function level in Python 2.7?
body: <p>I have written a relatively simple function in python that can be used to plot the time domain history of a data set as well as the frequency domain response of a data set after a fast fourier transform.  In this function I use the command <code>from pylab import *</code> to bring in all the necessary functionality.  However, despite successfully creating the plot, I get a warning stating </p>
  
  <blockquote>
    <p>import * only allowed at the module level.</p>
  </blockquote>
  
  <p>So if using the command <code>from pylab import *</code> is not the preferred methodology, how do I properly load all the necessary functionality from pylab.  The code is attached below.  Also, is there a way to close the figure after the function is exited, I have tried <code>plt.close()</code> which is not recognized for subplots?</p>
  
  <pre><code>def Time_Domain_Plot(Directory,Title,X_Label,Y_Label,X_Data,Y_Data):
      # Directory: The path length to the directory where the output file is 
      #            to be stored
      # Title:     The name of the output plot, which should end with .eps or .png
      # X_Label:   The X axis label
      # Y_Label:   The Y axis label
      # X_Data:    X axis data points (usually time at which Yaxis data was acquired
      # Y_Data:    Y axis data points, usually amplitude
  
      from pylab import *
      from matplotlib import rcParams
      rcParams.update({'figure.autolayout': True})
      Output_Location = Directory.rstrip() + Title.rstrip()
      fig,plt = plt.subplots()
      matplotlib.rc('xtick',labelsize=18)
      matplotlib.rc('ytick',labelsize=18)
      plt.set_xlabel(X_Label,fontsize=18)
      plt.set_ylabel(Y_Label,fontsize=18)
      plt.plot(X_Data,Y_Data,color='red')
      fig.savefig(Output_Location)
      plt.clear()
  </code></pre>