25
$\begingroup$

I want to express the ticks in scientific form. I tried two ways as following

ListLogPlot[Table[{x, 10^x}, {x, -1, 1}], Ticks -> {Automatic, {10^-1, 10^0, 10^1}}]

ListLogPlot[Table[{x, 10^x}, {x, -1, 1}],  
                          Ticks -> {Automatic, ScientificForm[{10^-1, 10^0, 10^1}]}]

enter image description here

but they just could not work as you can see; the latter even is wrong.

Why & how?

Edit by @belisarius

Scientific Notation is usually understood as ${1.\times 10^{-2}}$, however the OP wants just ${10^{-2}}$. Solutions for both cases can be found in the answers below.

$\endgroup$
2
  • $\begingroup$ I believe this is a duplicate but as my vote is binding I shall hold it for the time being: mathematica.stackexchange.com/q/5369/121 $\endgroup$
    – Mr.Wizard
    Aug 17, 2012 at 19:22
  • $\begingroup$ @Mr.Wizard , thanks! I should ever find that link before; however i failed to use proper key words. Anyway, i think the command Superscript is the simplest way to fulfill my requirement. $\endgroup$
    – Mathieu
    Aug 18, 2012 at 16:59

3 Answers 3

18
$\begingroup$

Here's one possibility. In this case, Superscript provides the needed format of exponents but Table helps in formatting Ticks over sets of values.

ListLogPlot[Table[PartitionsQ[n], {n, 50}], 
Ticks -> {Automatic, Table[{10^k, Superscript[10, k]}, {k, -2, 5}]},
PlotRange -> {Automatic, {1/1000, 10^5}}]

output

$\endgroup$
3
  • 1
    $\begingroup$ So far i found the Superscript is the easiest way to realize the 10^n format, as long as one notice the code need to be the form: {position, label} as Verde also pointed out. Thank you for your answer! $\endgroup$
    – Mathieu
    Aug 18, 2012 at 17:06
  • $\begingroup$ Thanks. Sometimes a simple approach will do the job. $\endgroup$
    – DavidC
    Aug 18, 2012 at 17:30
  • $\begingroup$ I'd rather use ScientificForm: Ticks -> {Automatic, Table[{10^k, ScientificForm[10^k]}, {k, -2, 5}]}, in this case $\endgroup$ May 29, 2020 at 4:05
15
$\begingroup$

You need the second form for the ticks {position, label}.

As in

ListLogPlot[#, Ticks -> {Automatic, {#, ScientificForm@#} & /@ #}] &@Array[10.^# &, 10]

Mathematica graphics

$\endgroup$
1
  • $\begingroup$ wow, ur code is very simple.It seems that the decimal point is crucial. If using Array[10^# &, 10], it goes back to ordinary form. Actually here i want the form like 10^1, 10^2,... without "1.". $\endgroup$
    – Mathieu
    Aug 18, 2012 at 5:18
14
$\begingroup$

I would suggest using the CustomTicks package. After loading the package, you do:

ListPlot[Table[{x, Log10[10^x]}, {x, -1, 1, .1}], Ticks -> {Automatic, LogTicks}]

Mathematica graphics

You can also specify to use CustomTicks's linear ticks:

ListPlot[Table[{x,Log10[10^x]},{x,-1,1,.1}],Ticks->{LinTicks,LogTicks}]

which gives a slightly different result:

Mathematica graphics

There are many options in this package to modify the ticks style, spacing, etc. See the complete user's guide.

$\endgroup$
1
  • $\begingroup$ That's powerful! I guess there would be one day i use that package for beautiful presentation. $\endgroup$
    – Mathieu
    Aug 18, 2012 at 17:01

Not the answer you're looking for? Browse other questions tagged or ask your own question.