Ticket #3853: trac_3880-referee.patch

File trac_3880-referee.patch, 11.7 kB (added by jason, 5 months ago)
  • a/sage/plot/plot.py

    old new  
    10381038        self.__ymax = yrange[1] 
    10391039        self.__objects.append(GraphicPrimitive_PlotField(xpos_array, ypos_array, xvec_array, yvec_array, options)) 
    10401040 
    1041     def _point(self, xdata, ydata, options): 
     1041    def _point(self, xdata, ydata, options, extend_axes=True): 
    10421042        """ 
    10431043        Add a plot of a point or list of points to this graphics object. 
    10441044 
     
    10501050            options -- dictionary of options 
    10511051        """ 
    10521052        self.__objects.append(GraphicPrimitive_Point(xdata, ydata, options)) 
    1053         self._extend_axes(*minmax_data(xdata, ydata)) 
    1054              
    1055     def _polygon(self, xdata, ydata, options): 
     1053        if extend_axes: 
     1054            self._extend_axes(*minmax_data(xdata, ydata)) 
     1055             
     1056    def _polygon(self, xdata, ydata, options, extend_axes=True): 
    10561057        """ 
    10571058        Add a plot of a polygon to this graphics object. 
    10581059 
     
    10641065            options -- dictionary of options 
    10651066        """ 
    10661067        self.__objects.append(GraphicPrimitive_Polygon(xdata, ydata, options)) 
    1067         self._extend_axes(*minmax_data(xdata, ydata))         
     1068        if extend_axes: 
     1069            self._extend_axes(*minmax_data(xdata, ydata))         
    10681070 
    10691071    def _text(self, string, point, options): 
    10701072        """ 
    1071         Add a countor plot to this graphics object. 
     1073        Add a string of text to this graphics object. 
    10721074 
    10731075        (For internal use -- you should just use addition.) 
    10741076 
     
    23302332        EXAMPLES:  
    23312333            sage: E = EllipticCurve('37a') 
    23322334            sage: P = E(0,0) 
    2333             sage: def get_points(n): return sum([point(i*P, pointsize=3) for i in range(-n,n) if i != 0 and (i*P)[0] < 3]) 
     2335            sage: def get_points(n): 
     2336            ....:     return sum([point((i*P)[0:2], pointsize=3) for i in range(-n,n) if i != 0 and (i*P)[0] < 3]) 
    23342337            sage: sum([get_points(15*n).plot3d(z=n) for n in range(1,10)]) 
    23352338        """ 
    23362339        from sage.plot.plot3d.base import Graphics3dGroup 
     
    26372640                NX.draw_networkx_labels(self.__nxg, self.__pos, labels=labels, ax=subplot) 
    26382641 
    26392642 
    2640 # WARNING: The below function xydata_from_point_list 
    2641 # can potentially be very slow for large point sets. 
    2642 
    2643 # It exists because it provides the following functionality: 
    2644 # Allows user to give as input to the function 'point' 
    2645 # a list of (x,y) values at which to plot points, coloring  
    2646 # each one a different color if needed.  From this input list we then 
    2647 # loop through it, first coercing all the values the floats 
    2648 # and then forming two new list that consist of all then 
    2649 # x-values in one list and all the y-values in another list. 
    2650 # This is needed to be done because that is how the input is 
    2651 # taken in the matplotlib function 'scatter'. 
     2643 
    26522644def xydata_from_point_list(points): 
    2653     if not isinstance(points, (list,tuple)) or \ 
    2654        (isinstance(points,(list,tuple)) and len(points) <= 3 \ 
    2655         and len(points) > 0 \ 
    2656         and not isinstance(points[0], (list,tuple))): 
     2645    r"""  
     2646    Returns two lists (xdata, ydata), each coerced to a list of 
     2647    floats, which correspond to the x-coordinates and the 
     2648    y-coordinates of the points. 
     2649 
     2650    The points parameter can be a list of 2-tuples or some object that 
     2651    yields a list of one or two numbers. 
     2652 
     2653    This function can potentially be very slow for large point sets. 
     2654 
     2655    """ 
     2656    if not isinstance(points, (list,tuple)): 
    26572657        try: 
    26582658            points = [[float(z) for z in points]] 
    26592659        except TypeError: 
    26602660            pass 
     2661    elif len(points)==2 and not isinstance(points[0], (list,tuple)): 
     2662        try: 
     2663            points = [[float(z) for z in points]] 
     2664        except TypeError: 
     2665            pass 
     2666     
     2667    if len(points)>0 and len(list(points[0]))!=2: 
     2668        print points 
     2669        raise ValueError, "points must have 2 coordinates in a 2d line" 
     2670 
     2671     
    26612672    xdata = [float(z[0]) for z in points] 
    26622673    ydata = [float(z[1]) for z in points]             
    26632674 
     
    27962807        2.0 
    27972808    """ 
    27982809    options={'alpha':1,'fill':False,'thickness':1,'rgbcolor':(0, 0, 1)} 
    2799     for k, v in kwds.iteritems(): 
    2800         options[k] = v 
     2810    options.update(kwds) 
    28012811 
    28022812    r = float(radius) 
    28032813    point = (float(point[0]), float(point[1])) 
     
    28782888        3.0 
    28792889    """ 
    28802890    options = {'plot_points':25, 'fill':True, 'cmap':'gray', 'contours':None} 
    2881     for k, v in kwds.iteritems(): 
    2882         options[k] = v 
     2891    options.update(kwds) 
    28832892 
    28842893    g, xstep, ystep, xrange, yrange = setup_for_eval_on_grid([f], xrange, yrange, options['plot_points']) 
    28852894    g = g[0] 
     
    29352944    """ 
    29362945    options = {'plot_points':25, 'fill':False, 'cmap':'gray', 'contours':(0.0,)} 
    29372946    options.update(kwds) 
    2938     return contour_plot(f, xrange, yrange, **kwds) 
     2947    return contour_plot(f, xrange, yrange, **options) 
    29392948 
    29402949def line(points, **kwds): 
    29412950    r""" 
     
    32273236    """ 
    32283237    options = {'alpha':1,'pointsize':10,'faceted':False,'rgbcolor':(0,0,1)} 
    32293238    options.update(kwds) 
    3230  
     3239     
    32313240    xdata, ydata = xydata_from_point_list(points) 
    32323241    g = Graphics(**minmax_data(xdata, ydata, dict=True)) 
    3233     g._Graphics__objects.append(GraphicPrimitive_Point(xdata, ydata, options)
     3242    g._point(xdata, ydata, options, extend_axes=False
    32343243    return g 
    32353244 
    32363245points = point 
     
    33103319     
    33113320    xdata, ydata = xydata_from_point_list(points) 
    33123321    g = Graphics(**minmax_data(xdata, ydata, dict=True)) 
    3313     g._Graphics__objects.append(GraphicPrimitive_Polygon(xdata, ydata, options)
     3322    g._polygon(xdata, ydata, options, extend_axes=False
    33143323    return g  
    33153324     
    33163325def plot(funcs, *args, **kwds): 
     
    34643473        sage: p.xmax() 
    34653474        120.0    
    34663475    """ 
    3467     do_show = False 
    3468     if kwds.has_key('show') and kwds['show']: 
    3469         do_show = True 
    3470         del kwds['show'] 
     3476    do_show = kwds.pop('show',False) 
    34713477    if hasattr(funcs, 'plot'): 
    34723478        G = funcs.plot(*args, **kwds) 
    34733479    # if we are using the generic plotting method 
     
    35183524    else: 
    35193525        f = funcs 
    35203526 
    3521     plot_points = int(options['plot_points']) 
    3522     del options['plot_points'] 
     3527    plot_points = int(options.pop('plot_points')) 
    35233528    x, data = var_and_list_of_values(xrange, plot_points) 
    35243529    data = list(data) 
    35253530    xmin = data[0] 
     
    36033608    return G 
    36043609 
    36053610 
    3606 def text(string, point, **kwds): 
    3607     r""" 
    3608     text(txt, point, **kwds): 
    3609      
    3610     Returns a 2d or 3d text graphics object at the point $(x,y)$ 
    3611  
    3612     Type \code{text.options} for a dictionary of options for 2d text.  The 3d options 
    3613     are as for other 3d graphics objects (i.e., mainly just rgbcolor at present).  
     3611def text(string, (x,y), **kwds): 
     3612    r""" 
     3613    Returns a 2d text graphics object at the point $(x,y)$. 
     3614 
     3615    Type \code{text.options} for a dictionary of options for 2d text. 
    36143616 
    36153617    2D OPTIONS: 
    36163618        fontsize -- How big the text is 
     
    36223624                       (0,0) is the lower left and (1,1) upper right, irregardless 
    36233625                       of the x and y range of plotted values.  
    36243626 
    3625     3D OPTIONS: 
    3626         rgbcolor -- the color of the text 
    3627  
    3628     EXAMPLES: 
    3629     Some 2d text: 
     3627    EXAMPLES: 
     3628    Some text: 
    36303629        sage: text("Sage is really neat!!",(2,12)) 
    36313630 
    3632     Some 2d text but guaranteed to be in the lower left no matter what: 
     3631    The same text in larger font and colored red: 
     3632        sage: text3d("Sage is really neat!!",(2,12),fontsize=20,rgbcolor=(1,0,0)) 
     3633 
     3634    Some text but guaranteed to be in the lower left no matter what: 
    36333635        sage: text("Sage is really neat!!",(0,0), axis_coords=True, horizontal_alignment='left') 
    36343636 
    3635     The same text, but in 3d: 
    3636         sage: text("Sage is really neat!!",(2,12,1)) 
    3637  
    3638     The same text in larger font and colored red: 
    3639         sage: text("Sage is really neat!!",(2,12),fontsize=20,rgbcolor=(1,0,0)) 
    3640  
    3641     And in 3d in two places: 
    3642         sage: text("Sage is...",(2,12,1), rgbcolor=(1,0,0)) + text("quite powerful!!",(4,10,0), rgbcolor=(0,0,1)) 
    3643  
    3644     You can also align 2d text differently: 
     3637    You can also align text differently: 
    36453638        sage: t1 = text("Hello",(1,1), vertical_alignment="top") 
    36463639        sage: t2 = text("World", (1,0.5), horizontal_alignment="left") 
    36473640        sage: t1 + t2   # render the sume 
     
    36523645               'axis_coords':False} 
    36533646    options.update(kwds) 
    36543647 
    3655     point = tuple(float(i) for i in point
     3648    point = (float(x), float(y)
    36563649    g = Graphics() 
    36573650    g._text(string, point, options) 
    36583651    return g 
  • a/sage/plot/plot3d/all.py

    old new  
    55 
    66from platonic          import tetrahedron, cube, octahedron, dodecahedron, icosahedron 
    77 
    8 from shapes2           import sphere, line3d, point3d 
     8from shapes2           import sphere, line3d, point3d, text3d 
    99 
    1010from shapes            import arrow3d 
    1111 
  • a/sage/plot/plot3d/shapes2.py

    old new  
    264264        (x,y,z) -- position 
    265265        **kwds -- standard 3d graphics options 
    266266 
    267     This function is called implicitly when you use the text command with a 3d position. 
    268  
    269267    NOTE: There is no way to change the font size or opacity yet.  
    270268 
    271269    EXAMPLES: 
    272270    We write the word SAGE in red at position (1,2,3): 
    273         sage: text("SAGE", (1,2,3), color=(0.5,0,0)) 
     271        sage: text3d("SAGE", (1,2,3), color=(0.5,0,0)) 
    274272 
    275273    We draw a multicolor spiral of numbers: 
    276         sage: sum([text('%.1f'%n, (cos(n),sin(n),n), color=(n/2,1-n/2,0)) \ 
     274        sage: sum([text3d('%.1f'%n, (cos(n),sin(n),n), color=(n/2,1-n/2,0)) \ 
    277275                    for n in [0,0.2,..,8]]) 
     276 
     277    Another example 
     278        sage: text3d("Sage is really neat!!",(2,12,1)) 
     279 
     280    And in 3d in two places: 
     281        sage: text3d("Sage is...",(2,12,1), rgbcolor=(1,0,0)) + text3d("quite powerful!!",(4,10,0), rgbcolor=(0,0,1)) 
     282 
     283 
    278284    """ 
    279285    if not kwds.has_key('color') and not kwds.has_key('rgbcolor'): 
    280286        kwds['color'] = (0,0,0) 
  • a/sage/rings/polynomial/groebner_fan.py

    old new  
    7777from sage.rings.integer import Integer 
    7878from sage.rings.integer_ring import ZZ 
    7979from sage.plot.plot import line, Graphics, polygon 
     80from sage.plot.plot3d.shapes2 import line3d 
    8081from sage.geometry.polyhedra import Polyhedron, ieq_to_vert, vert_to_ieq 
    8182 
    8283def prefix_check(str_list): 
     
    982983                raise RuntimeError 
    983984            for a_line in cone_lines: 
    984985                all_lines.append(a_line) 
    985         return sum([line(a_line) for a_line in all_lines]) 
     986        return sum([line3d(a_line) for a_line in all_lines]) 
    986987             
    987988    def _gfan_stats(self): 
    988989        """ 
  • a/sage/schemes/elliptic_curves/ell_finite_field.py

    old new  
    145145            raise NotImplementedError 
    146146 
    147147        G = plot.Graphics() 
    148         for P in self.points(): 
    149             if not P.is_zero(): 
    150                 G += plot.point(P, *args, **kwds) 
     148        G += plot.points([P[0:2] for P in self.points() if not P.is_zero()], *args, **kwds) 
     149 
    151150        return G 
    152151 
    153152    def _points_via_group_structure(self):