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

Tick labels in "classic" scientific format

1,347 views
Skip to first unread message

Kirzhanov

unread,
Jul 28, 2009, 5:28:00 PM7/28/09
to
Is it possible to draw tick labels in classic scientific format?
Command

set format y "%2.0t{/Symbol \327}10^{%L}"

works almost fine both for linear and logarithmic scale with one pity
exception: zero tick is printed as

0*10^0

instead of simple

0

A solution is to use latex+pgfplots for this task, but there are some
difficulties on this way. First (and main) is the compilation speed,
second (for my taste) is (delta x)/(delta y) ratio limitation. Maybe
something else...

Is there a simple but universal solution of this problem using Gnuplot?

Zoltan

unread,
Jul 29, 2009, 3:32:05 PM7/29/09
to
On 28 Jul., 23:28, Kirzhanov <kirzha...@gmail.com> wrote:
> Is it possible to draw tick labels in classic scientific format?
> Command
>
> set format y "%2.0t{/Symbol \327}10^{%L}"
>
> works almost fine both for linear and logarithmic scale with one pity
> exception: zero tick is printed as
>
> 0*10^0

That's interesting! In my experience, 0 never has come up on a
logarithmic scale:)

>
> instead of simple
>
> 0
>
> A solution is to use latex+pgfplots for this task, but there are some
> difficulties on this way. First (and main) is the compilation speed,
> second (for my taste) is (delta x)/(delta y) ratio limitation. Maybe
> something else...
>
> Is there a simple but universal solution of this problem using Gnuplot?

Apparently, there is no solution to this kind of problem, however,
even if there was, you would have a small issue with the alignment:
"0*10^0" is actually taller then "0", so, even if you can get rid of
"0*10^0", it is not clear how you would position your "0". All the
same, since I have also had this kind of problem a couple of times, I
would like to suggest that there be a "remove" tag in set xtics, or
even better, that the rule for the "add" tag be overwriting the label,
if one is at that particular position, instead of just adding the new
label to the list of xtics. I have looked at the code, and I believe,
all it would require is a search somewhere in the ticmark structure.
Please, correct me, if I am wrong.
Cheers,
Zoltán

Kirzhanov

unread,
Jul 31, 2009, 8:58:25 AM7/31/09
to
For my opinion, scientific format is useful for tick labels not only
on logarithmic scales but on linear too, and occurrence of Zero (0) on
such scales is not a very rare event. On my plots I prefer scientific
format like $6.67\times10^{-43}$ to something like 6.27e-43. Such
formatting mechanisms are implemented in many plotting systems,
including freeware (like pgfplots in latex) and proprietary (OriginLab
Origin). And it is a surprise for me to find out that this function
have never been required for users of Gnuplot.

By the way, there is a manual solution - to define the ticks and their
label using, for something like

set ytics ("-5{/Symbol \327}10^{-4}" 5e-4, "0" 0)

No unwanted shifts take place in this case. But... this is manual
solution :) It is not good enough for everyday plotting...

Is it possible to implement scientific formatting of labels in Gnuplot?

sfeam

unread,
Jul 31, 2009, 3:17:43 PM7/31/09
to
Kirzhanov wrote:

> Is it possible to draw tick labels in classic scientific format?
> Command
>
> set format y "%2.0t{/Symbol \327}10^{%L}"
>
> works almost fine both for linear and logarithmic scale with one pity
> exception: zero tick is printed as
>
> 0*10^0
>
> instead of simple
>
> 0
>

> Is there a simple but universal solution of this problem using Gnuplot?

The intent is that manually specified labels take precedence over
automatically generated labels. So the following is supposed to work

set xtics add ("0" 0)

But it doesn't work in this case.
So I will treat this as a bug report.

Kirzhanov

unread,
Aug 4, 2009, 12:17:20 PM8/4/09
to
By the way, when creating labels on an axis, it is not necessary:

1. to print 1.34 as 1.34*10^0 (1.34 looks good)
2. to print 1.67*10 as 1.67*10^1 (for me the label in form of 1.67*10
or 16.7 seems to be more common)

Some editors treat the longer versions of labels as an error. I think
that these examples (including the case of "0" label) show that code
like

set format y "%2.0t{/Symbol \327}10^{%L}"

is not a good solution for creating "automatic" labels in scientific
format.

sfeam

unread,
Aug 4, 2009, 2:06:32 PM8/4/09
to
Kirzhanov wrote:

sfeam >


> The intent is that manually specified labels take precedence over
> automatically generated labels. So the following is supposed to work
>
> set xtics add ("0" 0)
>
> But it doesn't work in this case.

S> o I will treat this as a bug report.

A bug fix is now in CVS, at least for 2D plots.

Can you point to a formal definition of "scientific format"?

Kirzhanov

unread,
Aug 7, 2009, 5:34:21 AM8/7/09
to
I could not find a formal definition or a guide that recommended to
follow the rules mentioned above. I like the way in which pgfplots
package (of latex) format the tick labels. It seems the formatting
algorithm of pgfplots chooses the format which gains a shorter
representation of the numeric label. The choice is made between "%g"
format and the format that is written as "%2.0t{/Symbol \327}10^{%L}"
in gnuplots.

The labels produced this way look fine. But this is only my private
opinion. I'm not sure it is necessary to use such an algorithm of
formatting on each plot. Moreover, format "%2.0t{/Symbol \327}10^{%L}"
seems to be preferred on most "purely" logarithmic scales. I cannot
say the same about linear and "mixed" (which contain a combination of
linear and logarithmic) scaled axes.

I believe that the possibility to choose a pgfplots-like
representation of tick labels in some cases might be useful in
postscript terminal (which as far as I know is often used to prepare
publication-ready figures).

0 new messages