Eric Firing wrote:
> 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
>
Thanks. Well, that explains a lot! functions in the wrong place.

I'm pretty new to this stuff, so what belongs where is sometimes 
unclear. I'll check out the sourceforge tip. I didn't write the program. 
I'm just trying to add some features. Changing the import for matplotlib 
got the graphics window up.
    import matplotlib.pyplot as plt

When I ran it, it was followed by this traceback:
------------start
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 508, in ShowHistogram
    plt.histogram(v, bins=linspace(0,256,nplt_bins+1), normed=1)# 
matplotlib version (plot)
AttributeError: 'module' object has no attribute 'histogram'
---------------end
508 line is the histogram. Who's complaining? ShowHistogram?  I don't 
believe I should be using hist here instead of histogram.

Off to sourceforge.

-- 
           Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

             (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
              Obz Site:  39° 15' 7" N, 121° 2' 32" W, 2700 feet  
                
          The popular press and many authorities believe the number
          of pedifiles that prowl the web is 50,00. There are no
          figures that support this. The number of children below
          18 years of age kidnapped by strangers is 1 in 600,00,
          or 115 per year. -- The Science of Fear by D. Gardner
 
                    Web Page: <www.speckledwithstars.net/>


------------------------------------------------------------------------------
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

Reply via email to