使用gnuplot在轴上显示2的幂 [英] Display powers of 2 on the axis with gnuplot
问题描述
我正在尝试使用gnuplot绘制实验结果.
I am trying to use gnuplot to plot results from my experiments.
我编写了一个C ++程序,该程序生成一个如下所示的数据文件:
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
我想要做的是将此数据文件的第一列的值显示为x的2的幂.它看起来像这样(不必看起来完全一样):
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
所以对于我发布的数据文件,我想在x轴上有2 ^ 10、2 ^ 11等. 知道怎么做吗?
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.
谢谢!
推荐答案
这可以通过操作using
规范相对容易地完成:
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.
使图看起来更好
这篇关于使用gnuplot在轴上显示2的幂的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!