# the first plot DOES NOT set the xlim and ylim properly
import numpy as np
import pylab as p
x = np.linspace(0.0,5.0,20)
slope = 1.0
intercept = 3.0
y = slope*x + intercept
p.set_xlim = ([0.0,10.0])
p.set_ylim = ([0.0,10.0])
p.plot(x,y)
p.show()
p.clf()
def xyplot():
slope = 1.0
intercept = 3.0
x = np.linspace(0.0,5.0,20)
y = slope*x + intercept
p.xlim([0.0,10.0])
p.ylim([0.0,10.0])
p.plot(x,y)
p.show()
# if I place the same exact code a a function, the xlim and ylim
# do …
Run Code Online (Sandbox Code Playgroud)