# HG changeset patch
# User Jason Grout <jasonsage@creativetrax.com>
# Date 1205530060 18000
# Node ID f7af50a89a2133bfe1226be61baadd6d8fba1519
# Parent bd7d421e02671580f4392cdb86e42559dd973a8c
Delete undefined values from the plot.
diff r bd7d421e0267 r f7af50a89a21 sage/plot/plot.py
a

b

class PlotFactory(GraphicPrimitiveFactor 
3315  3315  sage: plot([sin(n*x) for n in [1..4]], (0, pi)) 
3316  3316  
3317  3317  
3318   The function $\sin(1/x)$ wiggles wildtly near $0$, so the 
 3318  The function $\sin(1/x)$ wiggles wildly near $0$, so the 
3319  3319  first plot below won't look perfect. Sage adapts to this 
3320  3320  and plots extra points near the origin. 
3321  3321  sage: plot(sin(1/x), (x, 1, 1)) 
… 
… 
class PlotFactory(GraphicPrimitiveFactor 
3346  3346  We can change the line style to one of '' (dashed), '.' (dash dot), 
3347  3347  '' (solid), 'steps', ':' (dotted): 
3348  3348  sage: plot(sin(x), 0, 10, linestyle='.') 
 3349  
 3350  Sage currently ignores points that cannot be evaluated 
 3351  sage: plot(x*log(x), (x,0,1)) 
 3352  sage: plot(x^(1/3), (x,1,1)) 
 3353  
 3354  To plot the negative real cube root, use something like the following. 
 3355  sage: plot(lambda x : RR(x).nth_root(3), (x,1, 1) ) 
3349  3356  
3350  3357  TESTS: 
3351  3358  We do not randomize the endpoints: 
… 
… 
class PlotFactory(GraphicPrimitiveFactor 
3383  3390  elif n == 1: 
3384  3391  G = self._call(funcs, *args, **kwds) 
3385  3392  elif n == 2: 
3386   # if ther eare two extra args, then pull them out and pass them as a tuple 
 3393  # if there are two extra args, then pull them out and pass them as a tuple 
3387  3394  xmin = args[0] 
3388  3395  xmax = args[1] 
3389  3396  args = args[2:] 
… 
… 
class PlotFactory(GraphicPrimitiveFactor 
3437  3444  dd = delta 
3438  3445  
3439  3446  exceptions = 0; msg='' 
 3447  exception_indices = [] 
3440  3448  for i in range(plot_points): 
3441  3449  xi = xmin + i*delta 
3442  3450  # Slightly randomize points except for the first and last 
… 
… 
class PlotFactory(GraphicPrimitiveFactor 
3450  3458  try: 
3451  3459  y = f(xi) 
3452  3460  data[i] = (float (xi), float(y)) 
3453   except (ZeroDivisionError, TypeError, ValueError), msg: 
3454   sage.misc.misc.verbose("%s\nUnable to compute f(%s)"%(msg, x),1) 
 3461  except (ZeroDivisionError, TypeError, ValueError,OverflowError), msg: 
 3462  sage.misc.misc.verbose("%s\nUnable to compute f(%s)"%(msg, x),1) 
3455  3463  exceptions += 1 
3456   
 3464  exception_indices.append(i) 
 3465  data = [data[i] for i in xrange(len(data)) if i not in exception_indices] 
 3466  
3457  3467  # adaptive refinement 
3458  3468  i, j = 0, 0 
3459  3469  max_bend = float(options['max_bend']) 