Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

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

Search the Archive

Re: Number Formatting Along Axes

  • To: mathgroup at smc.vnet.net
  • Subject: [mg81460] Re: Number Formatting Along Axes
  • From: "David Park" <djmpark at comcast.net>
  • Date: Sun, 23 Sep 2007 21:22:46 -0400 (EDT)
  • References: <fd59bs$38o$1@smc.vnet.net>

It is a matter of writing a number formatting function with NumberForm and 
using most of the artillery. For your purpose the critical option is 
ExponentFunction. If the ExponentFunction applied to the number returns 
Null, then nonexponent formatting is used. So it is the Null Function and 
not just plain Null.

nformat[x_, digitlist_] :=
 Which[
  x == 0, 0,
  True,
  NumberForm[N[x], digitlist,
   NumberPadding -> {" ", "0"},
   NumberSigns -> {"-", " "},
   ExponentFunction -> (Null &),
   DigitBlock -> 3,
   NumberSeparator -> {"\[ThinSpace]", "\[ThinSpace]"}]]

Then, using DrawGraphics, I would use CustomTicks to generate the tick marks 
and labels. Here is a sample plot. NoTickLabels uses the same tick marks but 
gets rid of the labels.

Needs["DrawGraphics6`DrawingMaster`"]

yticks = CustomTicks[Identity, {-10^7, 10^7, 2.5*10^6, 5},
   CTNumberFunction -> (nformat[#, {8, 2}] &)];
Draw2D[
 {Draw[10^7 Sin[x], {x, 0, 2 \[Pi]}]},
 AspectRatio -> 1/2,
 Frame -> True,
 FrameLabel -> {x, f[x]},
 FrameTicks -> {{yticks, yticks // NoTickLabels}, {Automatic,
    Automatic}},
 PlotLabel -> "Nonscientific y Tick Labels",
 ImageSize -> 400]

However, a less cluttered set of labels can be obtained by putting the 
inverese exponent in the axis label and scaling the tick marks to a 
reasonable domain. This is what is usually done in scientific publications.

yticks = CustomTicks[# 10^7 &, {-1, 1, 0.25, 5},
   CTNumberFunction -> (nformat[#, {3, 2}] &)];
Draw2D[
 {Draw[10^7 Sin[x], {x, 0, 2 \[Pi]}]},
 AspectRatio -> 1/2,
 Frame -> True,
 FrameLabel -> {x,
   Style[Row[{f[x], " \[Times] \!\(\*SuperscriptBox[\"10\",
RowBox[{\"-\", \"7\"}]]\)"}], FontSize -> 12]},
 FrameTicks -> {{yticks, yticks // NoTickLabels}, {Automatic,
    Automatic}},
 PlotLabel -> "Nonscientific y Tick Labels",
 ImageSize -> 400]

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


"Bruce Colletti" <vze269bv at verizon.net> wrote in message 
news:fd59bs$38o$1 at smc.vnet.net...
> Re 6.0.1.
>
> By default, y-axis values display in scientific form.  How can a user 
> specify another format, e.g., XXXXX.XX or integer?
>
> Thankx.
>
> Bruce
> 



  • Prev by Date: XML parsing with patterns
  • Next by Date: Re: LegendreP error (bug?) in Mathematica
  • Previous by thread: Number Formatting Along Axes
  • Next by thread: Re: Number Formatting Along Axes