Name 'Plot' Is Not Defined

Name 'Plot' Is Not Defined

I installed succesfully scitools_no_easyviz from conda (I work on Spyder), but I cannot import plot. To be more specific, here's my code

from scitools.std import *

def f(t):
    return t**2*exp(-t**2)

t = linspace(0, 3, 51)
y = f(t)
plot(t, y)

savefig('tmp1.pdf') # produce PDF
savefig('tmp1.png') # produce PNG

figure()

def f(t):
    return t**2*exp(-t**2)

t = linspace(0, 3, 51)
y = f(t)
plot(t, y)
xlabel('t')
ylabel('y')
legend('t^2*exp(-t^2)')
axis([0, 3, -0.05, 0.6])   # [tmin, tmax, ymin, ymax]
title('My First Easyviz Demo')

figure()
plot(t, y)
xlabel('sss')

When I run the code, I get the following error

NameError: name 'plot' is not defined

What could be the problem?

1 Answer

Using import * is not considered a best practice, although very practical. Try importing the functions you need, such as:

from scitools.std import plot

Additionally, this way you will know if "plot" is valid when you import it along side any other function.

Ensure you have the dependencies installed in order to use the package as noted here at

Additionally, installed following these instruction latest package and your code runs perfectly well with it.

3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Robert Thorne
Author

Robert Thorne

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.