MathGroup Archive 2010

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

Search the Archive

A beginner with a problem

  • To: mathgroup at smc.vnet.net
  • Subject: [mg113936] A beginner with a problem
  • From: arw235 <arw235 at gmail.com>
  • Date: Thu, 18 Nov 2010 07:07:33 -0500 (EST)

In the following I am using a function to generate frameticks. The
ticks end up in decimal notation. I want the tick labels to be
rational numbers. I can't work out why the tick labels are defaulting
to decimals? Any help would be appreciated.

fticks[unit_, whole_] :=
  Partition[Riffle[Range[0, whole], Range[0, whole*1/unit, 1/unit]],
   2];

Manipulate[
 centersh = Table[{i, 1}, {i, col}];
 centersv = Table[{1, j}, {j, row}];
 farray =
  Flatten[Table[{i + 1, j + 1}, {i, col - 1}, {j, row - 1}], 1];

 pos = Join[
   Normal[
     GraphicsComplex[centersh,
      Table[{Disk[i, 1/2], Style[Inset[i, i], Yellow, Bold],
        Frame -> True}, {i, Length[centersh]}]]] /. {x_,
      y_} -> {x - 1/2, y - 1/2},
   Normal[
     GraphicsComplex[centersv,
      Table[{Disk[i, 1/2], Style[Inset[i, i], Yellow, Bold],
        Frame -> True}, {i, Length[centersv]}]]] /. {x_,
      y_} -> {x - 1/2, y - 1/2},
   Normal[
     GraphicsComplex[farray,
      Table[Disk[i, 1/2], {i, Length[farray]}]]] /. {x_,
      y_} -> {x - 1/2, y - 1/2}
   ];
 DynamicModule[{xunit, yunit},
  xticks := Dynamic[fticks[xunit, col]];
  yticks := Dynamic[fticks[yunit, row]];
  Column[{Row[{yticks, xticks}],
    Row[{"the factors of ", col}],
    Dynamic[SetterBar[Dynamic[xunit], Divisors[col]]],
    Row[{"The factor ", Dynamic[ xunit], "  gives the ",
      Dynamic[1/xunit], " parts of ", col*row}],
    Row[{"the factors of  ", row }],
    Dynamic[SetterBar[Dynamic[yunit], Divisors[row]]],
    Row[{"The factor ", Dynamic[ yunit], "  gives the ",
      Dynamic[1/yunit], " parts of ", col*row}],
    Graphics[pos, Frame -> True, ImageSize -> {400, 400},
     FrameTicks -> {{yticks, None}, {xticks, None}}]}]],
 {{col, 12, First_Factor}, 1, 24, 1}, {{row, 4, Second_Factor}, 1, 24,
   1}]


  • Prev by Date: Re: Does activating 8 disable 7?
  • Next by Date: Re: Does activating 8 disable 7?
  • Previous by thread: Re: solving a periodic function
  • Next by thread: JLink Java exception reading netcdf file via input