MathGroup Archive 1995

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

Search the Archive

Re: Tick control

  • To: mathgroup at christensen.cybernetics.net
  • Subject: [mg467] Re: [mg455] Tick control
  • From: Ross Moore <ross at zeus.mpce.mq.edu.au>
  • Date: Tue, 14 Feb 95 19:54:57 +1100

Hello Paul, and others

> ... I also
> don't want to explicitly write out each individual tick as 
> suggested in the Mathematica handbook. I would also like more
> control over the appearance of the ticks, such as length and
> thickness, without addressing each individual tick.


Here is a technique for (relatively) easy control over the
ticks in a 2-D or 3-D graphic, using Show, provided you know your  
1. PlotRange 
2. BoxRatios 
as well as 
3. the range of values that you want marked as ticks 
(which may be in a different coordinate system to the PlotRange).


It allows you to have Primary and Secondary ticks of different
lengths, labelling only the Primary ticks which occur every k-th
tick, starting after some given offset.
The `k' and `offset' can be different for each axis.


I tried to incorporate the `style' option for ticks (as a 4-th argument),
but could not get Thickness or Hue to produce any difference (Version 2.2.2)
despite what it says in the bible --- does anyone know what is wrong here?



(* Here is a set of parameters that I have used recently.  *)

fullRange= {{0,622},{0,362},{0,11/12}};
realBoxRatios={32.5, 19, 18};
tickRanges={Range[0,32],Range[0,18],Range[0,18]};
tickLabelSeps = {4,4,4};
tickOffsets={0,0,0};
{longTick,shortTick} = {.015,.01};
tickSpecifiers={({0,#})&,({0,#})&,({0,#})&};


(* this is the function that does all the work...  *)

tickMaker := Module[
	{ orig=fullRange[[#]]
	, ratio=realBoxRatios[[#]]
	, labelSep= tickLabelSeps[[#]]
	, tickRange=tickRanges[[#]]
	, offset=tickOffsets[[#]]
	, spec=tickSpecifiers[[#]]
(*	, style=tickStyles[[#]]	*)
	}
, Join[
	{(orig//First)+((orig//Last)-(orig//First))*#/ratio}
  , If[Mod[#-offset,labelSep]==0
  		, {#,spec@longTick}
  	(*	, {#,spec@longTick, style}	*)
  		, {"", spec@shortTick}
  		 ]
  ]& /@ tickRange ]& ;


(*  Here is how to use it with  Show ...  *)

Show[Graphics3D[{   (*  some graphics  *) }]
	, Axes->True
	, PlotRange->fullRange
	, BoxRatios->realBoxRatios
	, Ticks->(tickMaker/@Range[3])
	]



Enjoy the empty box.  :-)

Of course you could build a function which takes 
fullRange, realBoxRatios, tickRanges, etc.  
as arguments, rather than reading them as global variables.

More `functional' would be to define them as arguments to something
called `ShowWithTicks', which also does the Show, along with consistent
PlotRange and BoxRatios. 



Regards,
	Ross

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ross Moore                       Internet: ross at mpce.mq.edu.au
Mathematics Department              Work:       +61 2 850-8955
Macquarie University                Home:   please do not try
North Ryde, Sydney                   Fax:       +61 2 850-8114
Australia  2109		 WWW: http://www.mpce.mq.edu.au/~ross/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


  • Prev by Date: Mma and statistics
  • Next by Date: Mathematica Conference
  • Previous by thread: Tick control
  • Next by thread: Lie Groups