       Re: Ticks question

• To: mathgroup at smc.vnet.net
• Subject: [mg90183] Re: Ticks question
• From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
• Date: Tue, 1 Jul 2008 07:02:45 -0400 (EDT)
• Organization: The Open University, Milton Keynes, UK
• References: <g4a6ta\$8tv\$1@smc.vnet.net>

Aaron Fude wrote:

> 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?

You can extract the plot range for the x- and/or y-axis by pattern
matching (look a the FullForm of the graph, which is a Mathematica
expression since everything is an expression in Mathematica, to
understand why the Cases works).

Then, simple arithmetic will give the position and labels of the tick
marks depending on the number of marks you want. Note that you may have
to massage theses numbers with functions such as Round (or use one of
the many variations of Ticks to control labels and length; see "Moe
Information" for Ticks on the online help).

g = ParametricPlot[{Sin[u], Sin[2 u]}, {u, 0, 2 Pi}];
xr = Flatten@Cases[g, Rule[PlotRange, {x_, y_}] -> x, Infinity]
Show[g, Ticks -> {xr, Automatic}]
xr = Range[Min@xr, Max@xr, (Max@xr - Min@xr)/10]
Show[g, Ticks -> {xr, Automatic}]
FullForm[g]

Note that if you have of function of two parameters, you would have to
use FrameTicks rather than Ticks, since the plot is displayed by default
within a frame.

g = ParametricPlot[
r^2 { Sqrt[t] Cos[t], Sin[t]}, {t, 0, 3 Pi/2}, {r, 1, 2}];
xr = Flatten@Cases[g, Rule[PlotRange, {x_, y_}] -> x, Infinity]
Show[g, FrameTicks -> {xr, Automatic, None, None}]
xr = Round[Range[Min@xr, Max@xr, (Max@xr - Min@xr)/4]]
Show[g, FrameTicks -> {xr, Automatic, None, None}]

Regards,
-- Jean-Marc

• Prev by Date: Re: Bug of Units-package in combination with DynamicModule
• Next by Date: RE: Re: Bug in multiple integrals with delta function
• Previous by thread: Re: Ticks question
• Next by thread: Re: Ticks question