RE: Problems with TickFunction
- To: mathgroup at smc.vnet.net
- Subject: [mg40274] RE: [mg40260] Problems with TickFunction
- From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
- Date: Sat, 29 Mar 2003 05:19:15 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
>-----Original Message----- >From: Michael A. Gilchrist [mailto:mike at unm.edu] To: mathgroup at smc.vnet.net >Sent: Friday, March 28, 2003 10:32 AM >To: mathgroup at smc.vnet.net >Subject: [mg40274] [mg40260] Problems with TickFunction > > >Hi, > >I am trying to use the routines in ExtendGraphics`Tick`. >However, I keep >getting the same error when trying to use these functions. As far as I >can tell it stems from the fact that the subfunction TickPosition, >although defined, doesn't return any numbers > >Here's an example of a session > >Load Package > > In[12]:= > <<"ExtendGraphics`Ticks`" > >Try and run TickFunction > > In[15]:= > TickFunction[1,2,MajorStyle->{Thickness[0.02]}, > MajorLength->{0.06,0}] > > Transpose::nmtx: The first two levels of the one-dimensional list > {TickPosition[1,2,8],<<40>>[TickPosition[1,2,8]]} cannot be transposed. > > Transpose::nmtx: The first two levels of the one-dimensional list > >{TickPosition[1,2,8],<<40>>[<<1>>],{0.06,0},{Thickness[0.02]}} cannot be > transposed. > > Join::heads: Heads Transpose and TickPosition at positions 1 and 2 are > expected to be the same. > > Join[Transpose[{TickPosition[1,2,8], > >ExtendGraphics`Ticks`Private`TrimDecimal[TickPosition[1,2,8]],{ >0.06, 0}, > {Thickness[0.02]}}], >TickPosition[{32,,{0.003125,0},{Thickness[0.001]}}]] > > >If I inquire about TickPosition it appears to be defined > > In[13]:= > ?TickPosition > > Out[14]= > TickPosition[ min, max, num] returns a list of at most num nicely rounded > positions between min and max. These can be used for tick mark positions. > >However, when used the function just returns the command used >to call it > In[14]:= > TickPosition[1, 2, 5] > > Out[14]= > TickPosition[1,2,5] > > >Has anyone else seen this problem or does anyone have any ideas what's >going wrong here. > >Thanks in advance, > >Mike Gilchrist > > >BTW: I just reinstalled the ExtendGraphics files and that didn't help > > > Mike, what to do in such a case? You've already found out that there is a problem with TickPosition[1,2,8] So have a look at it: In[153]:= Begin["ExtendGraphics`Ticks`Private`"] Out[153]= "ExtendGraphics`Ticks`Private`" (this is a trick as to remove clutter in the output following, we're going to step right into the private part of the package) In[154]:= ?? TickPosition "TickPosition[ min, max, num] returns a list of at most num nicely rounded positions between min and max. These can be used for tick mark positions." TickPosition[x0_Real, x1_Real, num_Integer?Positive] := Block[{dist, scale, min, max, i, delta, space}, space = {1.`, 2.`, 2.5`, 5.`, 10.`}; dist = (x1 - x0)/num; scale = 10.`^Floor[Log[10, dist]]; dist = dist/scale; If[dist < 1.`, dist *= 10.`; scale = 10.`]; If[dist >= 10.`, dist = 10.`; scale *= 10.`]; delta = First[Select[space, #1 >= dist &]] scale; min = Ceiling[x0/delta] delta; Table[Floor[x/delta + 0.5`] delta, {x, min, x1, delta}]] In[155]:= End[] Out[155]= "ExtendGraphics`Ticks`Private`" (we have seen enough and leave) In[157]:= TickFunction[1., 2., MajorStyle -> {Thickness[0.02]}, MajorLength -> {0.06, 0}] ...works! -- Hartmut Wolf