python - NameError: global name 'imshow' is not defined but Matplotlib is imported -



python - NameError: global name 'imshow' is not defined but Matplotlib is imported -

i'm writing python script plots numpy matrix containing info (which i'm not having difficulty computing). complicated reasons having how i'm creating data, have go through terminal. i've done problems 1000000 times in spyder using imshow(). so, thought i'd seek same in terminal. here's code:

numpy import * matplotlib import * def make_picture(): f = open("data2.txt") arr = zeros((200, 200)) l = f.readlines() in l: j = i[:-1] k = j.split(" ") arr[int(k[0])][int(k[1])] = float(k[2]) f.close() imshow(arr) make_picture()

suffice say, array stuff works fine. i've tested it, , extracts info well. so, i've got 200 200 array of numbers floating around ram , i'd display it. when run code in spyder, expected. however, when run code in terminal, error message:

traceback (most recent phone call last): file "datamine.py", line 15, in <module> make_picture() file "datamine.py", line 13, in make_picture imshow(arr) nameerror: global name 'imshow' not defined

(my program's called datamine.py) what's deal here? there else should importing? know had configure spyder paths, wonder if don't have access paths or something. suggestions appreciated. thanks!

p.s. perhaps should mention i'm using ubuntu. don't know if that's relevant.

to create life easier can use

from pylab import *

this import total pylab package, includes matplotlib , numpy.

cheers

python numpy matplotlib terminal imshow

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -