Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display powers of 2 on the axis with gnuplot

Tags:

gnuplot

I am trying to use gnuplot to plot results from my experiments.

I wrote a C++ program that generates a datafile that looks like this:

10   3.5
11   3.5
12   3.5
13   3.6

What I am trying to do is to display the values of the first column of this datafile on the x-axis as powers of 2. It would look something like that (It doesn't have to look exactly the same):

http://i.stack.imgur.com/8BSLr.png

So with the datafile I posted, I want to have 2^10, 2^11, etc on the x axis. Any idea how to do that?

I can change the format of the datafile if needed.

Thanks!

like image 688
fireboot Avatar asked Dec 17 '12 13:12

fireboot


1 Answers

this is done relatively easy by manipulating the using specification:

plot datafile using (2**$1):2

If you do this, you'll probably also want a

set logscale x 2
set format x '2^{%L}'  #<- enhanced text.

to make the plot look nicer.

like image 194
mgilson Avatar answered Nov 03 '22 04:11

mgilson