# HG changeset patch
# User Ryan Grout <ayr035@gmail.com>
# Date 1294530030 21600
# Node ID 34c839b235471a0310ee530a26dec769094d3800
# Parent  fda5405ca19b1e36c6049949c705c9bce7652a30
Trac 7570: Passing empty lists to 2d functions returns empty Graphics() object

diff -r fda5405ca19b -r 34c839b23547 sage/plot/arrow.py
--- a/sage/plot/arrow.py	Fri Jan 07 17:17:56 2011 +0100
+++ b/sage/plot/arrow.py	Sat Jan 08 17:40:30 2011 -0600
@@ -405,6 +405,11 @@
 
         sage: line([(0,0),(1,0)],thickness=10)+line([(0,1),(1,1)], thickness=10)+arrow2d((0.5,0),(0.5,1), arrowshorten=10,rgbcolor=(1,0,0))
 
+    If BOTH headpoint and tailpoint are None, then an empty plot is returned::
+    
+        sage: arrow2d(headpoint=None, tailpoint=None)
+        
+    
     We can also draw an arrow with a legend::
 
         sage: arrow((0,0), (0,2), legend_label='up')
@@ -423,6 +428,8 @@
         g.add_primitive(Arrow(xtail, ytail, xhead, yhead, options=options))
     elif path is not None:
         g.add_primitive(CurveArrow(path, options=options))
+    elif tailpoint is None and headpoint is None:
+        return g
     else:
         raise TypeError('Arrow requires either both headpoint and tailpoint or a path parameter.')
     if options['legend_label']:
diff -r fda5405ca19b -r 34c839b23547 sage/plot/line.py
--- a/sage/plot/line.py	Fri Jan 07 17:17:56 2011 +0100
+++ b/sage/plot/line.py	Sat Jan 08 17:40:30 2011 -0600
@@ -394,7 +394,7 @@
 
     A line with no points or one point::
 
-        sage: line([])
+        sage: line([])      #returns an empty plot
         sage: line([(1,1)])
 
     A line with a legend::
@@ -407,6 +407,8 @@
         sage: line([(0,1), (3,4)]).show(figsize=[10, 2]) # These are equivalent
     """
     from sage.plot.plot import Graphics, xydata_from_point_list
+    if points == []:
+        return Graphics()
     xdata, ydata = xydata_from_point_list(points)
     g = Graphics()
     g._set_extra_kwds(Graphics._extract_kwds_for_show(options))
diff -r fda5405ca19b -r 34c839b23547 sage/plot/plot.py
--- a/sage/plot/plot.py	Fri Jan 07 17:17:56 2011 +0100
+++ b/sage/plot/plot.py	Sat Jan 08 17:40:30 2011 -0600
@@ -2707,6 +2707,13 @@
     as input::
     
         sage: plot([sin(n*x) for n in [1..4]], (0, pi))
+        
+    We can also build a plot step by step from an empty plot::
+    
+        sage: a = plot([]); a       # passing an empty list returns an empty plot (Graphics() object)
+        sage: a += plot(x**2); a    # append another plot
+        sage: a += plot(x**3); a    # append yet another plot
+        
     
     The function `\sin(1/x)` wiggles wildly near `0`.
     Sage adapts to this and plots extra points near the origin.
@@ -3003,6 +3010,8 @@
               polar=False, fill=False, label='', randomize=True, **options):
 
     from sage.plot.misc import setup_for_eval_on_grid
+    if funcs == []:
+        return Graphics()
     funcs, ranges = setup_for_eval_on_grid(funcs, [xrange], options['plot_points'])
     xmin, xmax, delta = ranges[0]
     xrange=ranges[0][:2]
@@ -3014,7 +3023,6 @@
     else:
         f = funcs
 
-
     #check to see if funcs is a list of functions that will
     #be all plotted together.
     if isinstance(funcs, (list, tuple)) and not parametric:
@@ -3393,7 +3401,10 @@
     all the data is drawn instead.
 
     If given a dictionary, ``list_plot`` interprets the keys as
-    `x`-values and the values as `y`-values. 
+    `x`-values and the values as `y`-values.
+
+    It is possible to pass empty dictionaries, lists, or tuples to list_plot.
+    Doing so will plot nothing (returning an unchanged plot).
 
     EXAMPLES::
     
@@ -3442,6 +3453,8 @@
         100.0
     """
     from sage.plot.all import line, point
+    if data == {} or data == () or data == []:
+        return Graphics()
     if isinstance(data, dict):
         if plotjoined:
             list_data = sorted(list(data.iteritems()))
diff -r fda5405ca19b -r 34c839b23547 sage/plot/point.py
--- a/sage/plot/point.py	Fri Jan 07 17:17:56 2011 +0100
+++ b/sage/plot/point.py	Sat Jan 08 17:40:30 2011 -0600
@@ -325,6 +325,10 @@
     A purple point from a single tuple or coordinates::
 
         sage: point((0.5, 0.5), rgbcolor=hue(0.75))
+        
+    Passing an empty list returns an empty plot::
+        
+        sage: point([])
 
     If you need a 2D point to live in 3-space later, 
     this is possible::
@@ -364,6 +368,8 @@
         sage: point((3,4), pointsize=100)
     """
     from sage.plot.plot import xydata_from_point_list, Graphics
+    if points == []:
+        return Graphics()
     xdata, ydata = xydata_from_point_list(points)
     g = Graphics()
     g._set_extra_kwds(Graphics._extract_kwds_for_show(options))
