MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Is it possible to query current plot range values (or have

  • To: mathgroup at
  • Subject: [mg110764] Re: Is it possible to query current plot range values (or have
  • From: "David Park" <djmpark at>
  • Date: Mon, 5 Jul 2010 06:02:48 -0400 (EDT)

The Presentations package has a command, DrawingWidths2D, that gives
knowledge of the bounding box of a set of graphics primitives, which can be
used while drawing other primitives. It returns the x and y ranges, the x
and y centers, and the min and max values of the bounding box.

For example, here we use it to find the bounding box of an ellipse produced
by a ContourPlot.


quadratic[x_, y_] := x^2 + 2 x y + 1.5 y^2 + 3 x - y + 2  
{{xrange, yrrange}, {xccenter, 
   ycenter}, {{xmin, xmax}, {ymin, ymax}}} =
    quadratic[x, y] == 0, {x, -15, 15}, {y, -15, 15}]}]  

{{9.94158, 8.11799}, {-5.50227, 
  4.00035}, {{-10.4731, -0.531481}, {-0.0586483, 8.05934}}} 

Here we use it to draw the ellipse and then add a vertical line that matches
the vertical range.

Module[{g, xrange, yrange, xcenter, ycenter, xmin, xmax, ymin, ymax},
 g = ContourDraw[quadratic, {x, -15, 15}, {y, -15, 15}, 
   PlotRange -> All];
 {{xrange, yrrange}, {xcenter, 
    ycenter}, {{xmin, xmax}, {ymin, ymax}}} = DrawingWidths2D[{g}];
   Line[{{xcenter, ymin}, {xcenter, ymax}}]},
  PlotRange -> All,
  ImageSize -> 300]

David Park
djmpark at  

From: Leo Alekseyev [mailto:dnquark at] 

Some of my plots contain vertical lines for alignment.  To make sure
the lines extend from the top to the bottom of the plot frame, I
typically give those lines large values for +y and -y coordinates.
This has an unfortunate side effect that the directive PlotRange->All
now considers my line to be a part of the plot, and rescales the plot
range to display it in its entirety.  Is there a way to (a) either
make PlotRange->All ignore this line somehow or (b) set the +y and -y
coordinates of the line to match the current plot range?..

Thanks in advance to anyone who might clarify this...

  • Prev by Date: Re: FindRoot with parameterized interpolated function from NDSolve
  • Next by Date: Re: Mathematica Collect function
  • Previous by thread: Re: Is it possible to query current plot range values (or have
  • Next by thread: how to tell Mathematica to display x^-1 as x^-1 and not as 1/x