how to nicely express an exponent for x/y axis?

how to nicely express an exponent for x/y axis?

Post by K. Le » Fri, 12 Feb 2010 22:45:07


Hello all,

My y axis has big numbers; for example,

8,000 9,000 10,000 11,000

So, I formated y axis like

set format y "$%.1t\\times{}10^{%L}$"

Now I have y axis expressed as

8.0 X 10^3 9.0 X 10^3 1.0 X 10^4 1.1 X 10^4

But the above numbers take too much space so I was wondering if I could
represent them as

0.8 0.9 1.0 1.1 and 10^4 on top of y axis

Basically, 10^4 is shared by all y numbers. I hope someone could help
me out with this problem. Thank you.
 
 
 

how to nicely express an exponent for x/y axis?

Post by Stefan Now » Fri, 12 Feb 2010 23:10:01


set format y "%.1f"
plot "yourdatafile" u 1:($2/1e4)

why do you want to playe the 10^4 on top of the y-axis (you can do this
using a label)? why dont you use: set ylabel "mydata $\\times 10^4$" ?

HTH
Stefan

 
 
 

how to nicely express an exponent for x/y axis?

Post by Stefan Now » Fri, 12 Feb 2010 23:11:27

Hi



set format y "%.1f"
plot "yourdatafile" u 1:($2/1e4)

why do you want to place the 10^4 on top of the y-axis (you can do this
using a label)? why don't you use: set ylabel "mydata $\\times 10^4$" or
whatever?

HTH
Stefan
 
 
 

how to nicely express an exponent for x/y axis?

Post by K. Le » Fri, 12 Feb 2010 23:47:49


Thank you for your suggestion. I'd like to put 10^4 on top of the y
axis to save some space as I said. Based on your idea, I can do like

set format y "$%.1t$"
set label "$\\times{}10^{5}$" at graph 0, 1.05
plot \
'mydata.txt' \
using ($0+1):($1/1e5) with points linestyle 1

But, 1) I need to manually adjust the location of "10^5" on top of the y
axis, and 2) I need to manually know what number I need to use -- could
be 10^4 or 10^5.
 
 
 

how to nicely express an exponent for x/y axis?

Post by Zolta » Sat, 13 Feb 2010 05:23:35

> But, 1) I need to manually adjust the location of "10^5" on top of the y

Sorry for butting in, but I thought that that was the idea: that you
can place 10^5 wherever you want to.


If you want to do it automatically, then you just have to call a dummy
plot before your actual plot, and deduce what the yrange is. So,
something like this should work:

set format y "$%.1t$"
plot 'foo' u 1:2 w l
lmax = int(log(GPVAL_Y_MAX))
expo = 10**lmax
set label sprintf("X 10^%d", lmax) at graph 0, 1.05
plot 'foo' u 1:($2/expo)

Cheers,
Zolt
 
 
 

how to nicely express an exponent for x/y axis?

Post by Zolta » Sat, 13 Feb 2010 05:25:55

> But, 1) I need to manually adjust the location of "10^5" on top of the y

Sorry for butting in, but I thought that that was the idea: that you
can place 10^5 wherever you want to.


If you want to do it automatically, then you just have to call a dummy
plot before your actual plot, and deduce what the yrange is. So,
something like this should work:

set format y "$%.1t$"
plot 'foo' u 1:2 w l
lmax = int(log10(GPVAL_Y_MAX))
expo = 10**lmax
set label sprintf("X 10^%d", lmax) at graph 0, 1.05
plot 'foo' u 1:($2/expo)

Cheers,
Zolt