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 1038 1038 self.__ymax = yrange[1] 1039 1039 self.__objects.append(GraphicPrimitive_PlotField(xpos_array, ypos_array, xvec_array, yvec_array, options)) 1040 1040 1041 def _point(self, xdata, ydata, options ):1041 def _point(self, xdata, ydata, options, extend_axes=True): 1042 1042 """ 1043 1043 Add a plot of a point or list of points to this graphics object. 1044 1044 … … 1050 1050 options -- dictionary of options 1051 1051 """ 1052 1052 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): 1056 1057 """ 1057 1058 Add a plot of a polygon to this graphics object. 1058 1059 … … 1064 1065 options -- dictionary of options 1065 1066 """ 1066 1067 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)) 1068 1070 1069 1071 def _text(self, string, point, options): 1070 1072 """ 1071 Add a countor plot to this graphics object.1073 Add a string of text to this graphics object. 1072 1074 1073 1075 (For internal use -- you should just use addition.) 1074 1076 … … 2330 2332 EXAMPLES: 2331 2333 sage: E = EllipticCurve('37a') 2332 2334 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]) 2334 2337 sage: sum([get_points(15*n).plot3d(z=n) for n in range(1,10)]) 2335 2338 """ 2336 2339 from sage.plot.plot3d.base import Graphics3dGroup … … 2637 2640 NX.draw_networkx_labels(self.__nxg, self.__pos, labels=labels, ax=subplot) 2638 2641 2639 2642 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 2652 2644 def 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)): 2657 2657 try: 2658 2658 points = [[float(z) for z in points]] 2659 2659 except TypeError: 2660 2660 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 2661 2672 xdata = [float(z[0]) for z in points] 2662 2673 ydata = [float(z[1]) for z in points] 2663 2674 … … 2796 2807 2.0 2797 2808 """ 2798 2809 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) 2801 2811 2802 2812 r = float(radius) 2803 2813 point = (float(point[0]), float(point[1])) … … 2878 2888 3.0 2879 2889 """ 2880 2890 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) 2883 2892 2884 2893 g, xstep, ystep, xrange, yrange = setup_for_eval_on_grid([f], xrange, yrange, options['plot_points']) 2885 2894 g = g[0] … … 2935 2944 """ 2936 2945 options = {'plot_points':25, 'fill':False, 'cmap':'gray', 'contours':(0.0,)} 2937 2946 options.update(kwds) 2938 return contour_plot(f, xrange, yrange, ** kwds)2947 return contour_plot(f, xrange, yrange, **options) 2939 2948 2940 2949 def line(points, **kwds): 2941 2950 r""" … … 3227 3236 """ 3228 3237 options = {'alpha':1,'pointsize':10,'faceted':False,'rgbcolor':(0,0,1)} 3229 3238 options.update(kwds) 3230 3239 3231 3240 xdata, ydata = xydata_from_point_list(points) 3232 3241 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) 3234 3243 return g 3235 3244 3236 3245 points = point … … 3310 3319 3311 3320 xdata, ydata = xydata_from_point_list(points) 3312 3321 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) 3314 3323 return g 3315 3324 3316 3325 def plot(funcs, *args, **kwds): … … 3464 3473 sage: p.xmax() 3465 3474 120.0 3466 3475 """ 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) 3471 3477 if hasattr(funcs, 'plot'): 3472 3478 G = funcs.plot(*args, **kwds) 3473 3479 # if we are using the generic plotting method … … 3518 3524 else: 3519 3525 f = funcs 3520 3526 3521 plot_points = int(options['plot_points']) 3522 del options['plot_points'] 3527 plot_points = int(options.pop('plot_points')) 3523 3528 x, data = var_and_list_of_values(xrange, plot_points) 3524 3529 data = list(data) 3525 3530 xmin = data[0] … … 3603 3608 return G 3604 3609 3605 3610 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). 3611 def 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. 3614 3616 3615 3617 2D OPTIONS: 3616 3618 fontsize -- How big the text is … … 3622 3624 (0,0) is the lower left and (1,1) upper right, irregardless 3623 3625 of the x and y range of plotted values. 3624 3626 3625 3D OPTIONS: 3626 rgbcolor -- the color of the text 3627 3628 EXAMPLES: 3629 Some 2d text: 3627 EXAMPLES: 3628 Some text: 3630 3629 sage: text("Sage is really neat!!",(2,12)) 3631 3630 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: 3633 3635 sage: text("Sage is really neat!!",(0,0), axis_coords=True, horizontal_alignment='left') 3634 3636 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: 3645 3638 sage: t1 = text("Hello",(1,1), vertical_alignment="top") 3646 3639 sage: t2 = text("World", (1,0.5), horizontal_alignment="left") 3647 3640 sage: t1 + t2 # render the sume … … 3652 3645 'axis_coords':False} 3653 3646 options.update(kwds) 3654 3647 3655 point = tuple(float(i) for i in point)3648 point = (float(x), float(y)) 3656 3649 g = Graphics() 3657 3650 g._text(string, point, options) 3658 3651 return g -
a/sage/plot/plot3d/all.py
old new 5 5 6 6 from platonic import tetrahedron, cube, octahedron, dodecahedron, icosahedron 7 7 8 from shapes2 import sphere, line3d, point3d 8 from shapes2 import sphere, line3d, point3d, text3d 9 9 10 10 from shapes import arrow3d 11 11 -
a/sage/plot/plot3d/shapes2.py
old new 264 264 (x,y,z) -- position 265 265 **kwds -- standard 3d graphics options 266 266 267 This function is called implicitly when you use the text command with a 3d position.268 269 267 NOTE: There is no way to change the font size or opacity yet. 270 268 271 269 EXAMPLES: 272 270 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)) 274 272 275 273 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)) \ 277 275 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 278 284 """ 279 285 if not kwds.has_key('color') and not kwds.has_key('rgbcolor'): 280 286 kwds['color'] = (0,0,0) -
a/sage/rings/polynomial/groebner_fan.py
old new 77 77 from sage.rings.integer import Integer 78 78 from sage.rings.integer_ring import ZZ 79 79 from sage.plot.plot import line, Graphics, polygon 80 from sage.plot.plot3d.shapes2 import line3d 80 81 from sage.geometry.polyhedra import Polyhedron, ieq_to_vert, vert_to_ieq 81 82 82 83 def prefix_check(str_list): … … 982 983 raise RuntimeError 983 984 for a_line in cone_lines: 984 985 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]) 986 987 987 988 def _gfan_stats(self): 988 989 """ -
a/sage/schemes/elliptic_curves/ell_finite_field.py
old new 145 145 raise NotImplementedError 146 146 147 147 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 151 150 return G 152 151 153 152 def _points_via_group_structure(self):