MathGroup Archive 2008

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

Search the Archive

Re: Ticks question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg90170] Re: Ticks question
  • From: "David Park" <djmpark at comcast.net>
  • Date: Tue, 1 Jul 2008 07:00:19 -0400 (EDT)
  • References: <g4a6ta$8tv$1@smc.vnet.net>

The Presentations package has a LinearScale routine that will pick a given 
number of 'even' tick values for a range.  This can then be used in 
CustomTicks to generate tick marks and labels. Here is an example that gets 
tick values by extracting the minimum and maximum values from a plotted 
line:

Needs["Presentations`Master`"]

Module[{g, work, minvalue, maxvalue, range, yticks},
 g = Draw[2 Sin[x] + x^2 - 3 x^3, {x, -2, 2}, PlotRange -> All];
 work = Join@
   Cases[g, Line[args_] :> Part[Transpose[args], 2], \[Infinity]];
 {minvalue, maxvalue} = {Min[work], Max[work]};
 range = maxvalue - minvalue;
 yticks = CustomTicks[Identity, LinearScale[minvalue, maxvalue, 8]];
 Draw2D[
  {g},
  AspectRatio -> 0.5,
  Frame -> True,
  FrameTicks -> {Automatic, yticks, Automatic,
    yticks // NoTickLabels},
  PlotRange -> All,
  PlotRangePadding -> {Automatic, 0.1 range},
  ImageSize -> 300]
 ]


There is also a command DrawingWidths2D (and 3D) that extracts the widths, 
center, and max and min values for a set of graphical primitives. Here is an 
example:

quadratic = x^2 + 2 x y + 1.5 y^2 + 3 x - y + 2 == 0;
{{xrange, yrange}, {xcenter, yccenter}, {{xmin, xmax}, {ymin, ymax}}} =
 DrawingWidths2D[{ContourDraw[quadratic, {x, -15, 15}, {y, -15, 15}]}]
{{9.94158,8.11799},{-5.50227,4.00035},{{-10.4731,-0.531481},{-0.0586483,8.05934}}}


However I think this has trouble with the Circle primitive where Mathematica 
doesn't take into account the radius.

-- 
David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/


"Aaron Fude" <aaronfude at gmail.com> wrote in message 
news:g4a6ta$8tv$1 at smc.vnet.net...
> Hi,
>
> Can't figure out: how does one ask for a certain number of tick marks
> without knowing what the range of the x-axis is as in ParametricPlot?
>
> For example, I want 4 tick marks.
>
> On a related note, suppose I want no tick marks but instead want to
> only see an indication of the range shown. How do I accomplish that?
> Perhaps it could be accomplished by having a single tick mark?
>
> Thanks!
> 



  • Prev by Date: Re: Controling the color of line segments in a Log plot
  • Next by Date: Jump to Page Mathematica Book
  • Previous by thread: Re: Ticks question
  • Next by thread: Possible Bug in Mathematica 6