From: Alan G I. <ala...@gm...> - 2010-06-08 16:39:46
|
On 6/8/2010 11:19 AM, Waléria Antunes David wrote: > the first function isdecrescent an the second is crescent Decreasing and increasing over the specified range, you mean. You won't see that when you plot them together because they have very different scales, so the one with the small scale will look flat. Alan Isaac PS I suspect you did integer division without intending to. Here's a fix for that. You might also want to check your parentheses, noting 1.0/2*4 is 2 (not 1/8), but I assumed you had what you wanted. import numpy as np import matplotlib.pyplot as plt x = np.arange(3000,3400, dtype=np.float) #use floats; not integers! x2 = x*x scale1 = -108 / 3e14**2 y1 = scale1 * x2 scale2 = 1*((1.38e-23*(1e0+4)/1e-6)*(1.0/4*(1e4**2)*(3e14**2))) scale2b = 1.38e19 * 11.25 #more accurate; less costly print scale2, scale2b, scale2 - scale2b # unnecessary error y2 = scale2b * x2 fig = plt.figure() ax = fig.add_subplot(1,2,1) ax.plot(x,y1) ax = fig.add_subplot(1,2,2) ax.plot(x,y2) fig = plt.figure() ax = fig.add_subplot(1,1,1) ax.plot(x, y1, label='y1') ax.plot(x, y2, label='y2') ax.legend() plt.show() |