Wayne Watson wrote: > I have a fairly large program that uses pylab and company. I want to use > the matplot histogram function. Here are the declarations at the start. > I added import matplotlib as mpl > ---------------------start > from Tkinter import * > from numpy import * > import numpy > import pylab > import Image > import ImageChops > import ImageTk > import time > import binascii > import tkMessageBox > import tkSimpleDialog > from pylab import plot, xlabel, ylabel, title, show, xticks, bar > import matplotlib as mpl <<<<---------- added > > from tkFileDialog import asksaveasfilename > from tkFileDialog import askopenfilename > > import MakeQTE > > import socket > > ... 500 lines of code > > I've added the follow code in a function > print "pltx_bins: ", pltx_bins > print "Off to pylab: ", plt_bins[0:nplt_bins] > fig = mpl.figure() > v = array(plt_bins) > print "v is: ",v > print "edges --", linspace(0,256,nplt_bins+1) > mpl.histogram(v, bins=linspace(0,256,nplt_bins+1), normed=1)# > matplotlib version (plot) > mpl.show() > print "end of histogram output" > # end of function > -------------------------end > The program dies at fig = figure() with: > Exception in Tkinter callback > Traceback (most recent call last): > File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__ > return self.func(*args) > File > "C:\Sandia_Meteors\Sentinel_Development\Development_Sentuser+Utilities\sentuser\sentuser_20090103+hist.py", > > line 504, in ShowHistogram > fig = mpl.figure() > TypeError: 'module' object is not callable > > What's the problem here? > >
figure(), show(), etc. are pylab (or matplotlib.pyplot) functions, not matplotlib functions. Especially for a long program, it is strongly recommended that you not use "from numpy import *". The recommended form is import numpy as np import matplotlib.pyplot as plt It will help you keep a clear picture of where various types of functionality are coming from. See also http://matplotlib.sourceforge.net/faq/usage_faq.html and note that a primarily object-oriented approach is recommended for use in other than quick scripts and interactive plotting. Eric ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users