I was trying to plot a function, but had a problem with the tick labels staying close to each other (top plot).

DiscretePlot[RmvsB[b], {b, bmin, bmax, bstep}]

enter image description here

So, I decided to play with the ticks increasing the labels step size and got the following result (bottom plot).

DiscretePlot[RmvsB[b], {b, bmin, bmax, bstep}, 
 Ticks -> { N[Table[i, {i, bmin, bmax, (bmax - bmin)/5}]], Automatic}]

As you can see the first number is in scientific format while the rest in the general form. Is there way to force the tick labels to show up in the scientific format, i.e Nx10^-7 ?

Another question is lets say the function argument range is in meters. Is there any way to convert meters to micrometers, i.e.a value of 100 would show up instead of the actual value of 1x10^-4?

Thanks a lot for your help

  • $\begingroup$ Take a look at ScientificForm $\endgroup$ – paw Sep 25 '14 at 0:58
  • $\begingroup$ I tried Ticks-> ScientificForm[N[Table[.....]]], it didn't work out. Elements used as ticks must be either a list or numbers. So, I am guessing Scientific format converts everything to string or smth, and it causes errors $\endgroup$ – Olzhas Sep 25 '14 at 1:36

To get the ticks in ScientificForm you have to provide the ticks in the following form: Tick->{{1,"Label1"},...}

bmin = 0;
bmax = 2*10^-5;
bstep = 1*10^-6;

DiscretePlot[-7*10^8 b + 15000 , {b, bmin, bmax, bstep},
 Ticks -> {Table[{i, ScientificForm[N@i, 3]}, {i, bmin, bmax, (bmax - bmin)/5}], Automatic}]

enter image description here

The unit conversion can be implemented with UnitConvert:

dataUnit = "m";
plotUnit = "nm";

DiscretePlot[-7*10^8 b + 15000 , {b, bmin, bmax, bstep}, 
 AxesLabel -> {plotUnit, None}, Ticks -> {Table[{i, 
   ScientificForm[N@i QuantityMagnitude@
      UnitConvert[Quantity[1, dataUnit], plotUnit], 3]}, {i, bmin, bmax, (bmax - bmin)/5}], Automatic}]

enter image description here

  • 1
    $\begingroup$ Awesome! Thanks a lot $\endgroup$ – Olzhas Oct 2 '14 at 19:47

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