# HG changeset patch
# User Jason Grout <jasonsage@creativetrax.com>
# Date 1276377726 18000
# Node ID db0a3682bd5a7cec7f484b80369006f8bcaa3568
# Parent 8210fcf8e8e204c16f050858a1dcfac6d2656713
#9211: Make graphs not cut off the vertices
diff r 8210fcf8e8e2 r db0a3682bd5a sage/graphs/graph_plot.py
a

b


198  198  if 'vertex_shape' in self._options: 
199  199  voptions['marker'] = self._options['vertex_shape'] 
200  200  
 201  # markersize is in points^2=(1/72 inches)^2. At 100dpi, this means 
 202  # that the radius is 
201  203  if self._graph.is_directed(): 
 204  # Assuming markersize is in data coordinates^2, this sets 
 205  # the vertex radius 
202  206  self._vertex_radius = sqrt(voptions['markersize']/pi) 
203  207  self._arrowshorten = 2*self._vertex_radius 
204  208  if self._arcdigraph: 
 209  # in this case, we plot the vertices using scatter 
 210  # plot. The constant below should be converting from 
 211  # points to data coordinates, but I don't think it's 
 212  # correct for that. 
205  213  self._vertex_radius = sqrt(voptions['markersize']/(20500*pi)) 
206  214  
207  215  voptions['zorder'] = 7 
… 
… 

209  217  if not isinstance(vertex_colors, dict): 
210  218  voptions['facecolor'] = vertex_colors 
211  219  if self._arcdigraph: 
212   self._plot_components['vertices'] = [circle(center, self._vertex_radius, fill=True, facecolor=vertex_colors) for center in self._pos.values()] 
 220  self._plot_components['vertices'] = [circle(center, self._vertex_radius, 
 221  fill=True, facecolor=vertex_colors) 
 222  for center in self._pos.values()] 
213  223  else: 
214   self._plot_components['vertices'] = scatter_plot(self._pos.values(), **voptions) 
 224  self._plot_components['vertices'] = scatter_plot(self._pos.values(), clip=False, 
 225  **voptions) 
215  226  else: 
216  227  # Color list must be ordered: 
217  228  pos = [] 
… 
… 

234  245  if self._arcdigraph: 
235  246  self._plot_components['vertices'] = [circle(pos[i], self._vertex_radius, fill=True, facecolor=colors[i]) for i in range(len(pos))] 
236  247  else: 
237   self._plot_components['vertices'] = scatter_plot(pos, facecolor=colors, **voptions) 
 248  self._plot_components['vertices'] = scatter_plot(pos, facecolor=colors, clip=False, 
 249  **voptions) 
238  250  
239  251  if self._options['vertex_labels']: 
240  252  self._plot_components['vertex_labels'] = [] 
diff r 8210fcf8e8e2 r db0a3682bd5a sage/plot/plot.py
a

b


445  445  self.__axes_width = 0.8 
446  446  self.__objects = [] 
447  447  self._extra_kwds = {} 
 448  self.__bbox_extra_artists = [] 
448  449  
449  450  def set_aspect_ratio(self, ratio): 
450  451  """ 
… 
… 

1650  1651  #add all the primitives to the subplot 
1651  1652  for g in self.__objects: 
1652  1653  g._render_on_subplot(subplot) 
 1654  if hasattr(g, '_bbox_extra_artists'): 
 1655  self.__bbox_extra_artists.extend(g._bbox_extra_artists) 
1653  1656  
1654  1657  
1655  1658  subplot.set_xlim([xmin, xmax]) 
… 
… 

1970  1973  dpi = 100 
1971  1974  else: 
1972  1975  raise ValueError, "file extension must be either 'png', 'ps, 'eps', 'pdf, 'svg' or 'sobj'" 
1973   figure.savefig(filename,dpi=dpi,bbox_inches='tight',**options) 
 1976  figure.savefig(filename,dpi=dpi,bbox_inches='tight', 
 1977  bbox_extra_artists=self.__bbox_extra_artists, **options) 
1974  1978  
1975  1979  
1976  1980  _SelectiveFormatterClass = None 
diff r 8210fcf8e8e2 r db0a3682bd5a sage/plot/scatter_plot.py
a

b


84  84  'hue':'The color given as a hue.', 
85  85  'facecolor':'The color of the marker face.', 
86  86  'edgecolor':'The color of the marker border.', 
87   'zorder':'The layer level in which to draw.'} 
 87  'zorder':'The layer level in which to draw.', 
 88  'clip': 'Whether or not to clip'} 
88  89  
89  90  def _repr_(self): 
90  91  """ 
… 
… 

107  108  """ 
108  109  from matplotlib.pyplot import scatter 
109  110  options = self.options() 
110   subplot.scatter(self.xdata, self.ydata, alpha=options['alpha'], zorder=options['zorder'], marker=options['marker'],s=options['markersize'],facecolors=options['facecolor'], edgecolors=options['edgecolor']) 
 111  p=subplot.scatter(self.xdata, self.ydata, alpha=options['alpha'], zorder=options['zorder'], marker=options['marker'],s=options['markersize'],facecolors=options['facecolor'], edgecolors=options['edgecolor'], clip_on=options['clip']) 
 112  if not options['clip']: 
 113  self._bbox_extra_artists=[p] 
111  114  
112   @options(alpha=1, markersize=50, marker='o', zorder=5, facecolor='#fec7b8', edgecolor='black') 
 115  @options(alpha=1, markersize=50, marker='o', zorder=5, facecolor='#fec7b8', edgecolor='black', clip=True) 
113  116  def scatter_plot(datalist, **options): 
114  117  """ 
115  118  Returns a Graphics object of a scatter plot containing all points in 