Display powers of 2 on the axis with gnuplot

旧街凉风 提交于 2019-12-19 18:29:33

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/13915483/display-powers-of-2-on-the-axis-with-gnuplot

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!