Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Scientific Notation in ListPlot Axes

1,051 views
Skip to first unread message

Patrick Spicer

unread,
Apr 6, 2004, 6:50:06 AM4/6/04
to
Hi,

I apologize up front for posting a seemingly FAQ...but I searched the
archives and did not find what I need.

How can I format the axis of a LogLinearListPlot to display tick
labels as scientific notation without the "1 x " portion? In other
words, I'd just like to display the base 10 and superscript exponent.
Here is an example of a plot whose x-axis I'd like to label in this
way:

data = {{10^-6,72},{10^-5,60},{10^-4,45},{10^-3,31},{10^-2,33},{10^-1,32}}
<< Graphics`Graphics`
LogLinearListPlot[data,
Ticks->{{10^-6,10^-5,10^-4,10^-3,10^-2,10^-1},Automatic},
PlotRange->{0, 100}]

Many thanks in advance for your help.

Best regards,

Pat

Bob Hanlon

unread,
Apr 7, 2004, 3:21:05 AM4/7/04
to
data={{10^-6,72},{10^-5,60},{10^-4,45},
{10^-3,31},{10^-2,33},{10^-1,32}};

Needs["Graphics`Graphics`"];

LogLinearListPlot[data,Ticks->{Table[
{10^-n,ScientificForm[1.*10^(-n),
NumberFormat->(10^#3&)]},{n,6}],
Automatic},PlotRange->{0,100}];

However, it is difficult to see the exponent on the labels. You could just use
the exponents.

LogLinearListPlot[data,
Ticks->{Table[{10^-n,-n},{n,6}],Automatic},
PlotRange->{0,100}, AxesLabel->{10^x,None}];


Bob Hanlon

In article <c4u20u$9ak$1...@smc.vnet.net>, psp...@fuse.net (Patrick Spicer)
wrote:

Jens-Peer Kuska

unread,
Apr 7, 2004, 3:22:07 AM4/7/04
to
Hi,

gr = LogLinearListPlot[data,
Ticks -> {({#, ScientificForm[N[#]]} & /@ {10^-6, 10^-5, 10^-4,
10^-3, 10^-2, 10^-1}), Automatic}, PlotRange -> {0, 100}];

Regards
Jens

David Park

unread,
Apr 7, 2004, 3:30:37 AM4/7/04
to
Patrick,

<< Graphics`Graphics`

data = {{10^-6, 72}, {10^-5, 60}, {10^-4, 45}, {10^-3, 31}, {10^-2,
33}, {10^-1, 32}};

xticks = Table[{N[10^n], ScientificForm[N[10^n], 1,
NumberFormat -> (#2^#3 & )]}, {n, -6, -1, 1}];

LogLinearListPlot[data,
Ticks -> {xticks, Automatic},
PlotRange -> {0, 100},
Prolog -> AbsolutePointSize[4]];

David Park
dj...@earthlink.net
http://home.earthlink.net/~djmp/

Riley Freeland

unread,
Apr 7, 2004, 3:37:06 AM4/7/04
to
The easiest way is to have the ticks be:

Ticks -> {Table[{10^x, DisplayForm[SuperscriptBox["10", x]]}, {x, -6,
-1}], Automatic}
Ticks -> {Table[{10^x, ScientificForm[1.*10^x, NumberFormat -> (10^#3
& )]}, {x, -6, -1}], Automatic}


Or, you can plot the data with automatic ticking, and replace the
ticklabels:

(* plot the data, without displaying it *)
plt = LogLinearListPlot[data, PlotRange -> {0, 100}, TextStyle ->
FontSize -> 12, DisplayFunction -> Identity];

(* strip out the major ticks, i.e. those with labels *)
majorTicks = Select[(Ticks /. AbsoluteOptions[plt])[[1]], #1[[2]] =!=
"" & ];

(* strip out the minor ticks, i.e. those without labels *)
minorTicks = Select[(Ticks /. AbsoluteOptions[plt])[[1]], #1[[2]] ===
"" & ];

(* replace the tick label with the proper formatting, and join them to
the minor ticks *)
xTicks = Join[(ReplacePart[##1, ScientificForm[#1[[2,1]], NumberFormat
-> (10^#3 & )], 2] & ) /@ majorTicks, minorTicks];

(* replot the data *)
Show[plt, Ticks -> {xTicks, Automatic}, DisplayFunction ->
$DisplayFunction];

Tomas Garza

unread,
Apr 7, 2004, 3:40:08 AM4/7/04
to
One obvious possibility (no doubt, there are much better ones):
In[1]:=
data = {{10^(-6), 72}, {10^(-5), 60}, {10^(-4), 45},
{10^(-3), 31}, {10^(-2), 33}, {10^(-1), 32}};


<< "Graphics`Graphics`"


LogLinearListPlot[data, Ticks ->
{{{10^(-6), "10^-6"}, {10^(-5), "10^-5"},
{10^(-4), "10^-4"}, {10^(-3), "10^-3"},
{10^(-2), "10^-2"}, {10^(-1), "10^-1"}},
Automatic}, PlotRange -> {0, 100}];

I.e., write your tick values as strings using the above correspondence.

Tomas Garza
Mexcio City

Tomas Garza

unread,
Apr 7, 2004, 3:41:16 AM4/7/04
to
This looks much better:

In[2]:=


data = {{10^(-6), 72}, {10^(-5), 60}, {10^(-4), 45},
{10^(-3), 31}, {10^(-2), 33}, {10^(-1), 32}};
<< "Graphics`Graphics`"
LogLinearListPlot[data, Ticks ->

{{{10^(-6), "\!\(10\^-6\)"}, {10^(-5), "\!\(10\^-5\)"},
{10^(-4), "\!\(10\^-4\)"}, {10^(-3), "\!\(10\^-3\)"},
{10^(-2), "\!\(10\^-2\)"}, {10^(-1), "\!\(10\^-1\)"}},


Automatic}, PlotRange -> {0, 100}];

Write the superscript expression with "10 Ctrl-6 -6", etc.

Tomas Garza

Mexico City

Kevin J. McCann

unread,
Apr 7, 2004, 8:42:33 PM4/7/04
to
I tried all of the suggestions on this, and except for the 10^-6 tick, I get
it in decimal form, e.g. 0.00001.

Kevin

"Bob Hanlon" <bobh...@aol.com> wrote in message
news:c50a51$msl$1...@smc.vnet.net...

0 new messages