RE: make 1. x 10^-10 read 10^-1
- To: mathgroup at smc.vnet.net
- Subject: [mg8705] RE: [mg8574] make 1. x 10^-10 read 10^-1
- From: Ersek_Ted%PAX1A at mr.nawcad.navy.mil
- Date: Fri, 19 Sep 1997 02:47:46 -0400
- Sender: owner-wri-mathgroup at wolfram.com
Rob Peterson wrote: || ||That silly "1 x" in front of a power of ten sure does waste graphics ||space. Can anyone tell me how to format the numbers along an axis? ||Thanks for any help, Rob || | |Something like the following might help: | |Plot[funct, {x, xmin, xmax}, ticks->{{10^3, Superscript[10,3]}, {10^6, |Superscript[10,6]}, {10^9, Superscript[10,9]}} ] | | |************************* |Ted, thanks a lot for the suggestion. I have actually read a lot in the |mma book but mostly the book tells me nothing. The little they mention about labels |and tick marks, I simply can't understand. Anyhow, I attempted your suggestion and |here is what I got: | .......... | .......... | .......... |The last paragraph is the error message from mma. I tried LogPlot, no |help. Can you tell what I did wrong? | Yeh I had some syntax errors in "ticks->.........." Well I couldn't find a simple solution. However, I think I found a some what long way to do just what you want. see below: In[1]:= (* Make a Plot. *) plt=Plot[x^2/Log[x], {x, 10^9, 10^23}, DisplayFunction->Identity]; (* This tests wether (x) of the form 1. 10^n_Integer. *) PowerTenQ[x_Real]:= If[Part[MantissaExponent[x], 1]==0.1, True, False] PowerTenQ[_]:=False In[2]:= (* I will use this new label when PowerTenQ is True. *) NewLabel[1.0]=1; NewLabel[10.0]=10; NewLabel[x_Real]:= Superscript[10, Part[MantissaExponent[x], 2]-1] NewLabel[x_?NumericQ]:=x In[7]:= (* This ensures I don't show a coefficient for (1.x 10^n) *) RemoveOnes[lst_List]:=lst/. {x:(_?PowerTenQ),x_,others___}->{x,NewLabel[x],others} (* Make a plot with new numbers on tick marks. *) tcks=Ticks/.FullOptions[plt]; newtks=Map[RemoveOnes[#]&,tcks]; Show[plt,Ticks->newtks, DisplayFunction->$DisplayFunction] Out[]= -Graphics- ------ figure not shown --------- If you really like this you can put it in a package. If you don't understand how it works let me know. I can explain. Ted Ersek ersek_ted%pax1a at mr.nawcad.navy.mil