Display power 2 on axis using gnuplot

I am trying to use gnuplot to build the results of my experiments.

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

10 3.5 11 3.5 12 3.5 13 3.6 

What I'm trying to do is show the x-axis values ​​of the first column of this data file as powers of 2. This will look something like this (it shouldn't look exactly the same):

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

So, with the published data file, I want to have 2 ^ 10, 2 ^ 11, etc. along the x axis. Any idea how to do this?

I can change the data file format if necessary.

Thanks!

+6
source share
1 answer

this is done relatively easily by using specification:

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

If you do this, you will probably also need

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

to make the plot more enjoyable.

+11
source

All Articles