MathGroup Archive 2008

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

Search the Archive

Re: Equi-sized tick labels

  • To: mathgroup at smc.vnet.net
  • Subject: [mg85309] Re: Equi-sized tick labels
  • From: "David Park" <djmpark at comcast.net>
  • Date: Tue, 5 Feb 2008 19:43:40 -0500 (EST)
  • References: <fo9fia$s3i$1@smc.vnet.net>

I wonder about this.

There is a bug in Mathematica graphics such that when one supplies one's own 
Tick specifications, the plot does not initially display the correct tick 
lengths on the x-axis. But if you select the plot and resize it, then the x 
ticks will snap to the specification. If you go with the Automatic Ticks 
then the problem does not occur.

I prepared some Tick specifications using your prescription. I did it using 
Presentations, which I will show for record, but I will also copy the 
resulting Tick specifications into the posting. I did use a more rectangular 
AspectRatio because the bug is more apparent then.

Needs["Presentations`Master`"]

With[
 {ticksize = 0.02,
  smallticksize = 0.01,
  aspectratio = 0.4},
 xticks =
  CustomTicks[Identity, {0, 3.5, 1, 5}, CTTickSpecs -> {ticksize, 0},
   CTUnLabTickSpecs -> {smallticksize, 0}];
 yticks =
  CustomTicks[Identity, {0, 3.5, 1, 5},
   CTTickSpecs -> {ticksize/aspectratio, 0},
   CTUnLabTickSpecs -> {smallticksize/aspectratio, 0}];]

So here is the example:

xticks = {{0, 0, {0.02, 0}, {GrayLevel[0.], AbsoluteThickness[0.25]}}, {1,
  1, {0.02, 0}, {GrayLevel[0.], AbsoluteThickness[0.25]}}, {2,
  2, {0.02, 0}, {GrayLevel[0.], AbsoluteThickness[0.25]}}, {3,
  3, {0.02, 0}, {GrayLevel[0.], AbsoluteThickness[0.25]}}, {1/5,
  "", {0.01, 0}, {GrayLevel[0.], AbsoluteThickness[0.125]}}, {2/5,
  "", {0.01, 0}, {GrayLevel[0.], AbsoluteThickness[0.125]}}, {3/5,
  "", {0.01, 0}, {GrayLevel[0.], AbsoluteThickness[0.125]}}, {4/5,
  "", {0.01, 0}, {GrayLevel[0.], AbsoluteThickness[0.125]}}, {6/5,
  "", {0.01, 0}, {GrayLevel[0.], AbsoluteThickness[0.125]}}, {7/5,
  "", {0.01, 0}, {GrayLevel[0.], AbsoluteThickness[0.125]}}, {8/5,
  "", {0.01, 0}, {GrayLevel[0.], AbsoluteThickness[0.125]}}, {9/5,
  "", {0.01, 0}, {GrayLevel[0.], AbsoluteThickness[0.125]}}, {11/5,
  "", {0.01, 0}, {GrayLevel[0.], AbsoluteThickness[0.125]}}, {12/5,
  "", {0.01, 0}, {GrayLevel[0.], AbsoluteThickness[0.125]}}, {13/5,
  "", {0.01, 0}, {GrayLevel[0.], AbsoluteThickness[0.125]}}, {14/5,
  "", {0.01, 0}, {GrayLevel[0.], AbsoluteThickness[0.125]}}, {16/5,
  "", {0.01, 0}, {GrayLevel[0.], AbsoluteThickness[0.125]}}, {17/5,
  "", {0.01, 0}, {GrayLevel[0.], AbsoluteThickness[0.125]}}}

yticks = {{0, 0, {0.05, 0}, {GrayLevel[0.], AbsoluteThickness[0.25]}}, {1,
  1, {0.05, 0}, {GrayLevel[0.], AbsoluteThickness[0.25]}}, {2,
  2, {0.05, 0}, {GrayLevel[0.], AbsoluteThickness[0.25]}}, {3,
  3, {0.05, 0}, {GrayLevel[0.], AbsoluteThickness[0.25]}}, {1/5,
  "", {0.025, 0}, {GrayLevel[0.], AbsoluteThickness[0.125]}}, {2/5,
  "", {0.025, 0}, {GrayLevel[0.], AbsoluteThickness[0.125]}}, {3/5,
  "", {0.025, 0}, {GrayLevel[0.], AbsoluteThickness[0.125]}}, {4/5,
  "", {0.025, 0}, {GrayLevel[0.], AbsoluteThickness[0.125]}}, {6/5,
  "", {0.025, 0}, {GrayLevel[0.], AbsoluteThickness[0.125]}}, {7/5,
  "", {0.025, 0}, {GrayLevel[0.], AbsoluteThickness[0.125]}}, {8/5,
  "", {0.025, 0}, {GrayLevel[0.], AbsoluteThickness[0.125]}}, {9/5,
  "", {0.025, 0}, {GrayLevel[0.], AbsoluteThickness[0.125]}}, {11/5,
  "", {0.025, 0}, {GrayLevel[0.], AbsoluteThickness[0.125]}}, {12/5,
  "", {0.025, 0}, {GrayLevel[0.], AbsoluteThickness[0.125]}}, {13/5,
  "", {0.025, 0}, {GrayLevel[0.], AbsoluteThickness[0.125]}}, {14/5,
  "", {0.025, 0}, {GrayLevel[0.], AbsoluteThickness[0.125]}}, {16/5,
  "", {0.025, 0}, {GrayLevel[0.], AbsoluteThickness[0.125]}}, {17/5,
  "", {0.025, 0}, {GrayLevel[0.], AbsoluteThickness[0.125]}}}

With[
 {ticksize = 0.02,
  smallticksize = 0.01,
  aspectratio = 0.4,
  padratio = 1.5},
 SetOptions[Plot,
  AspectRatio -> aspectratio,
  Frame -> True,
  FrameTicks -> {{yticks, Automatic}, {xticks, Automatic}},
  PlotRangePadding -> {Scaled[padratio ticksize],
    Scaled[padratio ticksize/aspectratio]},
  ImageSize -> 450];
 Plot[x, {x, 0, \[Pi]}]]

The xticks and yticks don't look anywhere the same size. Furthermore, if you 
select and adjust the size of the plot you will see that the x ticks snap to 
a new larger size. (The Automatic ticks are unaffected.)

Unless I'm making some error, I don't see that this method works and, in any 
case, the bug of an incorrect initial display (without resizing) is still 
there.


-- 
David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/


"Will Robertson" <wspr81 at gmail.com> wrote in message 
news:fo9fia$s3i$1 at smc.vnet.net...
> Dear all,
>
> When Mathematica creates tick marks in plots, it uses a ratio of the
> plot size to calculate their length. Unfortunately, it treats
> horizontal and vertical sizes separately so non-square plots will have
> unequal tick marks in the two different directions. This can look
> rather ugly, in my opinion.
>
> Luckily, it's an easy problem to fix. Please find attached some code
> to "normalise" the length of the ticks used in plots so that non-
> square plots don't have uneven ticks horizontally and vertically. It
> uses the CustomTicks package, whose author I shall contact about
> rolling this functionality into his package.
>
> Have fun,
> Will
>
> Here is the code. It may be modified and distributed freely under the
> Apache Licence, v2.
>
> << "CustomTicks`"
>
> ticksize := 0.02
> smallticksize := 0.01
> aspectratio := 0.8
> padratio := 1.5
>
> XTicks[a_, b_, opts___] := LinTicks[a, b,
>  MajorTickLength -> {ticksize, 0},
>  MinorTickLength -> {smallticksize, 0},
>  opts
>  ]
> YTicks[a_, b_, opts___] := LinTicks[a, b,
>  MajorTickLength -> {ticksize/aspectratio, 0},
>  MinorTickLength -> {smallticksize/aspectratio, 0},
>  opts
>  ]
>
> EmptyXTicks[a_, b_] := XTicks[a, b, ShowTickLabels -> False]
> EmptyYTicks[a_, b_] := YTicks[a, b, ShowTickLabels -> False]
>
> SetOptions[Plot, Frame -> True, AspectRatio -> aspectratio,
>  FrameTicks -> {{XTicks, EmptyXTicks}, {YTicks, EmptyYTicks}},
>  PlotRangePadding ->
>   {Scaled[padratio*ticksize],
>    Scaled[padratio*ticksize/aspectratio]}];
> Plot[x, {x, 0, \[Pi]}]
> 



  • Prev by Date: Re: silly problem
  • Next by Date: How should I start with mathematica?
  • Previous by thread: Re: Equi-sized tick labels
  • Next by thread: Re: Equi-sized tick labels