0

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 Answers1

0

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 https://code.google.com/archive/p/scitools/wikis/Installation.wiki

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

glls
  • 2,325
  • 1
  • 22
  • 39