Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

Re: Ticks question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg90156] Re: Ticks question
  • From: Januk <ggroup at sarj.ca>
  • Date: Tue, 1 Jul 2008 06:57:40 -0400 (EDT)
  • References: <g4a6ta$8tv$1@smc.vnet.net>

Here is one option to answer your first question:

pl1 = ParametricPlot[{.05 Sin[t], .03 Cos[5 t]}, {t, 0, 2 \[Pi]},
   PlotRange -> All];

CustomTicks[pl1_Graphics, xticks_Integer: 10, yticks_Integer: 10,
  opts___?OptionQ] :=
 Module[{pr, xmin, xmax, dx, xrng, rdx, ymin, ymax, dy, yrng, rdy,
   xtickloc, ytickloc},
  pr = PlotRange /. AbsoluteOptions[pl1, PlotRange];

  {xmin, xmax} = pr[[1]];
  xrng = xmax - xmin;
  dx = xrng/xticks;
  rdx = RealDigits[dx, 10, 1];

  xtickloc =
   Round[#, 10.^(rdx[[2]] - 3)] &@
    Table[i, {i, xmin + dx/2, xmax - dx/2, dx}];

  {ymin, ymax} = pr[[2]];
  yrng = ymax - ymin;
  dy = yrng/yticks;
  rdy = RealDigits[dy, 10, 1];

  ytickloc =
    Round[#, 10.^(rdy[[2]] - 3)] &@
     Table[i, {i, ymin + dy/2, ymax - dy/2, dy}];


  Show[pl1, opts, Ticks -> {xtickloc, ytickloc}]
  ]

CustomTicks[pl1, 5, 3]

Hope that helps.
Januk

On Jun 30, 4:52 am, Aaron Fude <aaronf... at gmail.com> wrote:
> 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: How to plot discontinuous functions?
  • Next by Date: Re: How to plot discontinuous functions?
  • Previous by thread: Re: Ticks question
  • Next by thread: Re: Ticks question