Ticket #2100: trac_2100-auto-automatic-and-vector.patch

File trac_2100-auto-automatic-and-vector.patch, 10.1 KB (added by kcrisman, 8 years ago)

Apply after rebase patch

  • sage/plot/bar_chart.py

    # HG changeset patch
    # User Karl-Dieter Crisman <kcrisman@gmail.com>
    # Date 1297738595 18000
    # Node ID 398687a996483a352a91e318bdd2fb30f424edb7
    # Parent  be86952efaf5568c677b98b7ba0f8b342d89ebf6
    Trac # 2100 - change new default aspect ratio to do 'automatic' instead of 'auto'.
    
    This also fixes vector plotting.
    
    diff -r be86952efaf5 -r 398687a99648 sage/plot/bar_chart.py
    a b  
    119119        subplot.bar(ind, datalist, color=color, width=width, label=options['legend_label'])
    120120
    121121@rename_keyword(color='rgbcolor')
    122 @options(width=0.5, rgbcolor=(0,0,1), legend_label=None, aspect_ratio='auto')
     122@options(width=0.5, rgbcolor=(0,0,1), legend_label=None, aspect_ratio='automatic')
    123123def bar_chart(datalist, **options):
    124124    """
    125125    A bar chart of (currently) one list of numerical data.
  • sage/plot/line.py

    diff -r be86952efaf5 -r 398687a99648 sage/plot/line.py
    a b  
    275275
    276276   
    277277@rename_keyword(color='rgbcolor')
    278 @options(alpha=1, rgbcolor=(0,0,1), thickness=1, legend_label=None)
     278@options(alpha=1, rgbcolor=(0,0,1), thickness=1, legend_label=None, aspect_ratio ='automatic')
    279279def line2d(points, **options):
    280280    r"""
    281281    Create the line through the given list of points.
  • sage/plot/plot.py

    diff -r be86952efaf5 -r 398687a99648 sage/plot/plot.py
    a b  
    470470        """
    471471        Set the aspect ratio, which is the ratio of height and width
    472472        of a unit square (i.e., height/width of a unit square), or
    473         'auto' (expand to fill the figure).
     473        'automatic' (expand to fill the figure).
    474474       
    475475        INPUT:
    476476       
    477477       
    478         -  ``ratio`` - a positive real number or 'auto'
     478        -  ``ratio`` - a positive real number or 'automatic'
    479479       
    480480       
    481481        EXAMPLES: We create a plot of a circle, and it doesn't look quite
     
    501501            sage: P + Q
    502502            sage: Q + P
    503503        """
    504         if ratio != 'auto':
     504        if ratio != 'auto' and ratio != 'automatic':
    505505            ratio = float(ratio)
    506506            if ratio <= 0:
    507                 raise ValueError, "the aspect ratio must be positive or 'auto'"
     507                raise ValueError, "the aspect ratio must be positive or 'automatic'"
     508        else:
     509            ratio = 'automatic'
    508510        self.__aspect_ratio = ratio
    509511
    510512    def aspect_ratio(self):
    511513        """
    512514        Get the current aspect ratio, which is the ratio of height to
    513         width of a unit square, or 'auto'.
    514        
    515         OUTPUT: a positive float (height/width of a unit square), or 'auto'
     515        width of a unit square, or 'automatic'.
     516       
     517        OUTPUT: a positive float (height/width of a unit square), or 'automatic'
    516518        (expand to fill the figure).
    517519       
    518520        EXAMPLES::
     
    523525            sage: P.set_aspect_ratio(2)
    524526            sage: P.aspect_ratio()
    525527            2.0
    526             sage: P.set_aspect_ratio('auto')
     528            sage: P.set_aspect_ratio('automatic')
    527529            sage: P.aspect_ratio()
    528             'auto'
     530            'automatic'
    529531        """
    530532        return self.__aspect_ratio
    531533
     
    12511253        The xmin, xmax, ymin, and ymax properties of the graphics objects
    12521254        are expanded to include all objects in both scenes. If the aspect
    12531255        ratio property of either or both objects are set, then the larger
    1254         aspect ratio is chosen, with 'auto' being overridden by a
     1256        aspect ratio is chosen, with 'automatic' being overridden by a
    12551257        numeric aspect ratio.
    12561258
    12571259        If one of the graphics object is set to show a legend, then the
     
    12681270
    12691271        Extra keywords to show are propagated::
    12701272
    1271             sage: (g1 + g2)._extra_kwds=={'aspect_ratio': 'auto', 'frame': True}
     1273            sage: (g1 + g2)._extra_kwds=={'aspect_ratio': 'automatic', 'frame': True}
    12721274            True
    12731275        """
    12741276        if isinstance(other, int) and other == 0:
     
    12801282            raise TypeError, "other (=%s) must be a Graphics objects"%other
    12811283        g = Graphics()
    12821284        g.__objects = self.__objects + other.__objects
    1283         if self.__aspect_ratio=='auto':
     1285        if self.__aspect_ratio=='automatic':
    12841286            g.__aspect_ratio=other.__aspect_ratio
    1285         elif other.__aspect_ratio=='auto':
     1287        elif other.__aspect_ratio=='automatic':
    12861288            g.__aspect_ratio=self.__aspect_ratio
    12871289        else:
    12881290            g.__aspect_ratio = max(self.__aspect_ratio, other.__aspect_ratio)
     
    14201422          will look round and a unit square will appear to have sides
    14211423          of equal length. If the aspect ratio is set ``2``, vertical units will be
    14221424          twice as long as horizontal units, so a unit square will be twice as
    1423           high as it is wide.  If set to ``'auto'``, the aspect ratio
     1425          high as it is wide.  If set to ``'automatic'``, the aspect ratio
    14241426          is determined by ``figsize`` and the picture fills the figure.
    14251427
    14261428        - ``axes`` - (default: True)
     
    19681970            subplot = figure.add_subplot(111)
    19691971        if aspect_ratio is None:
    19701972            aspect_ratio=self.aspect_ratio()
    1971         subplot.set_aspect(aspect_ratio, adjustable='box')
     1973        if aspect_ratio == 'automatic':
     1974            subplot.set_aspect('auto', adjustable='box')
     1975        else:
     1976            subplot.set_aspect(aspect_ratio, adjustable='box')
    19721977        #add all the primitives to the subplot
    19731978        for g in self.__objects:
    19741979            g._render_on_subplot(subplot)
     
    26912696@rename_keyword(color='rgbcolor')
    26922697@options(alpha=1, thickness=1, fill=False, fillcolor='automatic', fillalpha=0.5, rgbcolor=(0,0,1), plot_points=200,
    26932698         adaptive_tolerance=0.01, adaptive_recursion=5, detect_poles = False, exclude = None, legend_label=None,
    2694          __original_opts=True, aspect_ratio='auto')
     2699         __original_opts=True, aspect_ratio='automatic')
    26952700def plot(funcs, *args, **kwds):
    26962701    r"""
    26972702    Use plot by writing
     
    35353540    kwds['polar']=True
    35363541    return plot(funcs, *args, **kwds)
    35373542
    3538 @options(aspect_ratio='auto')
     3543@options(aspect_ratio='automatic')
    35393544def list_plot(data, plotjoined=False, **kwargs):
    35403545    r"""
    35413546    ``list_plot`` takes either a single list of data, a list of tuples,
  • sage/plot/plot3d/base.pyx

    diff -r be86952efaf5 -r 398687a99648 sage/plot/plot3d/base.pyx
    a b  
    947947            opts['aspect_ratio'] = (1, 1, 1)
    948948        if not isinstance(opts['aspect_ratio'], (str, list, tuple)):
    949949            raise TypeError, 'aspect ratio must be a string, list, tuple, or 1'
     950        # deal with any aspect_ratio instances passed from the default options to plot
     951        if opts['aspect_ratio'] == 'auto':
     952            opts['aspect_ratio'] = 'automatic'
    950953
    951954        if opts['frame_aspect_ratio'] == 'automatic':
    952955            if opts['aspect_ratio'] != 'automatic':
     
    10291032
    10301033            sage: sphere((0,0,0))
    10311034
    1032         EXAMPLES: We illustrate use of the aspect_ratio option::
     1035        EXAMPLES: We illustrate use of the ``aspect_ratio`` option::
    10331036
    10341037            sage: x, y = var('x,y')
    10351038            sage: p = plot3d(2*sin(x*y), (x, -pi, pi), (y, -pi, pi))
     
    10431046
    10441047            sage: p.show(aspect_ratio=[1,1,1], frame_aspect_ratio=[1,1,1/8])
    10451048
     1049        This example shows indirectly that the defaults
     1050        from :func:`~sage.plot.plot.plot` are dealt with properly::
     1051
     1052            sage: plot(vector([1,2,3]))
     1053
    10461054        We use the 'canvas3d' backend from inside the notebook to get a view of
    10471055        the plot rendered inline using HTML canvas::
    10481056
  • sage/plot/plot3d/plot_field3d.py

    diff -r be86952efaf5 -r 398687a99648 sage/plot/plot3d/plot_field3d.py
    a b  
    5757        sage: plot_vector_field3d((x*cos(z),-y*cos(z),sin(z)), (x,0,pi), (y,0,pi), (z,0,pi),plot_points=4)
    5858        sage: plot_vector_field3d((x*cos(z),-y*cos(z),sin(z)), (x,0,pi), (y,0,pi), (z,0,pi),plot_points=[3,5,7])
    5959        sage: plot_vector_field3d((x*cos(z),-y*cos(z),sin(z)), (x,0,pi), (y,0,pi), (z,0,pi),center_arrows=True)
     60
     61    TESTS:
     62
     63    This tests that Trac # 2100 is fixed in a way compatible with this command::
     64
     65        sage: plot_vector_field3d((x*cos(z),-y*cos(z),sin(z)), (x,0,pi), (y,0,pi), (z,0,pi),center_arrows=True,aspect_ratio=(1,2,1))
    6066    """
    6167    (ff,gg,hh), ranges = setup_for_eval_on_grid(functions, [xrange, yrange, zrange], plot_points)
    6268    xpoints, ypoints, zpoints = [srange(*r, include_endpoint=True) for r in ranges]
  • sage/plot/point.py

    diff -r be86952efaf5 -r 398687a99648 sage/plot/point.py
    a b  
    312312        return point3d(points, **kwds)
    313313
    314314@rename_keyword(color='rgbcolor', pointsize='size')
    315 @options(alpha=1, size=10, faceted=False, rgbcolor=(0,0,1), legend_label=None)
     315@options(alpha=1, size=10, faceted=False, rgbcolor=(0,0,1), legend_label=None, aspect_ratio='automatic')
    316316def point2d(points, **options):
    317317    r"""
    318318    A point of size ``size`` defined by point = `(x,y)`.
  • sage/plot/scatter_plot.py

    diff -r be86952efaf5 -r 398687a99648 sage/plot/scatter_plot.py
    a b  
    128128        options = self.options()
    129129        subplot.scatter(self.xdata, self.ydata, alpha=options['alpha'], zorder=options['zorder'], marker=options['marker'],s=options['markersize'],facecolors=options['facecolor'], edgecolors=options['edgecolor'])
    130130
    131 @options(alpha=1, markersize=50, marker='o', zorder=5, facecolor='#fec7b8', edgecolor='black', aspect_ratio='auto')
     131@options(alpha=1, markersize=50, marker='o', zorder=5, facecolor='#fec7b8', edgecolor='black', aspect_ratio='automatic')
    132132def scatter_plot(datalist, **options):
    133133    """
    134134    Returns a Graphics object of a scatter plot containing all points in