# HG changeset patch
# User Punarbasu Purkayastha <ppurka@gmail.com>
# Date 1382407104 28800
# Node ID 4a2501c8b79c1e5922202eb21dc11c808dab8d85
# Parent 69c1cf4a08321aa2b9e47a0a912adf0fdbc251b8
fix aspect_ratio for density_plot
diff git a/sage/plot/density_plot.py b/sage/plot/density_plot.py
a

b


42  42  
43  43  EXAMPLES: 
44  44  
45   Note this should normally be used indirectly via `density_plot``:: 
 45  Note this should normally be used indirectly via ``density_plot``:: 
46  46  
47  47  sage: from sage.plot.density_plot import DensityPlot 
48  48  sage: D = DensityPlot([[1,3],[2,4]],(1,2),(2,3),options={}) 
… 
… 

220  220  :: 
221  221  
222  222  sage: density_plot(log(x) + log(y), (x, 1, 10), (y, 1, 10)).show(dpi=20) # These are equivalent 
 223  
 224  TESTS: 
 225  
 226  Check that :trac:`15315` is fixed, i.e., density_plot respects the 
 227  ``aspect_ratio`` parameter. Without the fix, it looks like a thin line 
 228  of width a few mm. With the fix it should look like a nice fat layered 
 229  image:: 
 230  
 231  sage: density_plot((x*y)^(1/2), (x,0,3), (y,0,500), aspect_ratio=.01) 
 232  
 233  Default ``aspect_ratio`` is ``"automatic"``, and that should work too:: 
 234  
 235  sage: density_plot((x*y)^(1/2), (x,0,3), (y,0,500)) 
 236  
223  237  """ 
224  238  from sage.plot.all import Graphics 
225  239  from sage.plot.misc import setup_for_eval_on_grid 
diff git a/sage/plot/graphics.py b/sage/plot/graphics.py
a

b


2213  2213  subplot = sub 
2214  2214  if not subplot: 
2215  2215  subplot = figure.add_subplot(111) 
2216   if aspect_ratio is None: 
2217   aspect_ratio=self.aspect_ratio() 
2218   if aspect_ratio == 'automatic': 
2219   subplot.set_aspect('auto', adjustable='box') 
2220   else: 
2221   subplot.set_aspect(aspect_ratio, adjustable='box') 
2222  2216  #add all the primitives to the subplot 
2223  2217  old_opts = dict() 
2224  2218  for g in self._objects: 
… 
… 

2231  2225  g._render_on_subplot(subplot) 
2232  2226  if hasattr(g, '_bbox_extra_artists'): 
2233  2227  self._bbox_extra_artists.extend(g._bbox_extra_artists) 
 2228  # Set the aspect ratio 
 2229  if aspect_ratio is None: 
 2230  aspect_ratio=self.aspect_ratio() 
 2231  if aspect_ratio == 'automatic': 
 2232  subplot.set_aspect('auto', adjustable='box') 
 2233  else: 
 2234  subplot.set_aspect(aspect_ratio, adjustable='box') 
2234  2235  
2235  2236  # Set the scale # 
2236  2237  xscale, yscale, basex, basey = self._set_scale(figure, scale=scale, 