Ticket #11677: trac_11677_fillFixes.patch

File trac_11677_fillFixes.patch, 2.0 KB (added by peter.story, 10 years ago)
  • sage/plot/polygon.py

    # HG changeset patch
    # User Peter Story <peter.story@gordon.edu>
    # Date 1326233233 18000
    # Node ID 04cd64254e542961d86c2fc5877be946b3a402cf
    # Parent  21e906fe80d6008253ad68c16870105d6af68981
    Fixed fill argument, thickness now defaults to 1 when fill=False.
    
    diff --git a/sage/plot/polygon.py b/sage/plot/polygon.py
    a b  
    165165        """
    166166        if options is None:
    167167            options = dict(self.options())
    168         if 'thickness' in options:
    169             del options['thickness']
    170         if 'zorder' in options:
    171             del options['zorder']
    172         if 'legend_label' in options:
    173             del options['legend_label']
     168        for o in ['thickness', 'zorder', 'legend_label', 'fill']:
     169            options.pop(o, None)
    174170        return GraphicPrimitive_xydata._plot3d_options(self, options)
    175171
    176172    def plot3d(self, z=0, **kwds):
     
    242238        a = float(options['alpha'])
    243239        z = int(options.pop('zorder', 1))
    244240        p.set_alpha(a)
     241        f = options.pop('fill')
     242        p.set_fill(f)
    245243        c = to_mpl_color(options['rgbcolor'])
    246244        p.set_edgecolor(c)
    247245        p.set_facecolor(c)
     
    274272        return polygon3d(points, **options)
    275273
    276274@rename_keyword(color='rgbcolor')
    277 @options(alpha=1, rgbcolor=(0,0,1), thickness=0, legend_label=None)
     275@options(alpha=1, rgbcolor=(0,0,1), thickness=None, legend_label=None, fill=True)
    278276def polygon2d(points, **options):
    279277    r"""
    280278    Returns a polygon defined by ``points``.
     
    343341   
    344342    """
    345343    from sage.plot.plot import xydata_from_point_list, Graphics
     344    if options["thickness"] is None:    # If the user did not specify thickness
     345        if options["fill"]:                 # If the user chose fill
     346            options["thickness"] = 0
     347        else:
     348            options["thickness"] = 1
    346349    xdata, ydata = xydata_from_point_list(points)
    347350    g = Graphics()
    348351    g._set_extra_kwds(Graphics._extract_kwds_for_show(options))