Ticket #9211: trac_9211_digraph_clipping.patch

File trac_9211_digraph_clipping.patch, 4.2 KB (added by jason, 10 years ago)

apply after trac-9211-fix_cut_vertices_in_graphs.patch

  • sage/graphs/graph_plot.py

    # HG changeset patch
    # User Jason Grout <jason.grout@drake.edu>
    # Date 1318342457 18000
    # Node ID c6d10c32282b730285ece9658c7ea01cd3b4c7f2
    # Parent  ea0895090e4cccc010028a9f8ea420f8dc4c5ed6
    Don't clip digraph vertices and don't clip text ever (by default).
    
    diff --git a/sage/graphs/graph_plot.py b/sage/graphs/graph_plot.py
    a b  
    238238            voptions['facecolor'] = vertex_colors
    239239            if self._arcdigraph:
    240240                self._plot_components['vertices'] = [circle(center,
    241                     self._vertex_radius, fill=True, facecolor=vertex_colors)
     241                    self._vertex_radius, fill=True, facecolor=vertex_colors, clip=False)
    242242                    for center in self._pos.values()]
    243243            else:
    244244                self._plot_components['vertices'] = scatter_plot(
     
    264264
    265265            if self._arcdigraph:
    266266                self._plot_components['vertices'] = [circle(pos[i],
    267                     self._vertex_radius, fill=True, facecolor=colors[i])
     267                    self._vertex_radius, fill=True, facecolor=colors[i], clip=False)
    268268                    for i in range(len(pos))]
    269269            else:
    270270                self._plot_components['vertices'] = scatter_plot(pos,
  • sage/plot/circle.py

    diff --git a/sage/plot/circle.py b/sage/plot/circle.py
    a b  
    116116                'rgbcolor':'The color (edge and face) as an RGB tuple.',
    117117                'hue':'The color given as a hue.',
    118118                'zorder':'2D only: The layer level in which to draw',
    119                 'linestyle':"2D only: The style of the line, which is one of 'dashed', 'dotted', 'solid', 'dashdot'."}
     119                'linestyle':"2D only: The style of the line, which is one of 'dashed', 'dotted', 'solid', 'dashdot'.",
     120                'clip': 'Whether or not to clip the circle.'}
    120121
    121122    def _repr_(self):
    122123        """
     
    138139        """
    139140        import matplotlib.patches as patches       
    140141        options = self.options()
    141         p = patches.Circle((float(self.x), float(self.y)), float(self.r))
     142        p = patches.Circle((float(self.x), float(self.y)), float(self.r), clip_on=options['clip'])
     143        if not options['clip']:
     144            self._bbox_extra_artists=[p]
    142145        p.set_linewidth(float(options['thickness']))
    143146        p.set_fill(options['fill'])
    144147        a = float(options['alpha'])
     
    210213            return Line(xdata, ydata, options).plot3d().translate((0,0,z))
    211214
    212215@rename_keyword(color='rgbcolor')
    213 @options(alpha=1, fill=False, thickness=1, edgecolor='black', facecolor='red', linestyle='solid', zorder=5, legend_label=None)
     216@options(alpha=1, fill=False, thickness=1, edgecolor='black', facecolor='red', linestyle='solid',
     217         zorder=5, legend_label=None, clip=True)
    214218def circle(center, radius, **options):
    215219    """
    216220    Return a circle at a point center = `(x,y)` (or `(x,y,z)` and
  • sage/plot/text.py

    diff --git a/sage/plot/text.py b/sage/plot/text.py
    a b  
    101101                'rotation': 'how to rotate the text: angle in degrees, vertical, horizontal',
    102102                'vertical_alignment': 'how to align vertically: top, center, bottom',
    103103                'horizontal_alignment':'how to align horizontally: left, center, right',
    104                 'zorder':'The layer level in which to draw'}
     104                'zorder':'The layer level in which to draw',
     105                'clip': 'Whether to clip or not.'}
    105106
    106107    def _plot3d_options(self, options=None):
    107108        """
     
    177178                opts['rotation'] = options['rotation']
    178179            else:
    179180                opts['rotation'] = float(options['rotation'])
    180         subplot.text(self.x, self.y, self.string, **opts)
     181        p=subplot.text(self.x, self.y, self.string, clip_on=options['clip'], **opts)
     182        if not options['clip']:
     183            self._bbox_extra_artists=[p]
     184
    181185
    182186@rename_keyword(color='rgbcolor')
    183187@options(fontsize=10, rgbcolor=(0,0,1), horizontal_alignment='center',
    184          vertical_alignment='center', axis_coords=False)
     188         vertical_alignment='center', axis_coords=False, clip=False)
    185189def text(string, xy, **options):
    186190    r"""
    187191    Returns a 2D text graphics object at the point `(x,y)`.