英文:
gnuplot - How do I change xrange when changing x-axis scale?º
问题
我有以下数据:
100 100.0
500 499.8
1000 999.0
2000 1994.4
3000 2918.8
10000 8233.8
99999 9433.2
我想绘制图表,使得所有x轴标签等间隔。参考此链接,我制作了以下脚本:
set terminal png size 500,500
set output 'throughput.png'
set title 'Connection throughput'
plot 'throughput.txt' using 0:2:xticlabel(1) title "Throughput"
我得到了以下结果。
尽管如此,我希望数据点从100到99999的值可见。为了解决这个问题,我尝试使用set xrange [0,110000]
指令。结果如下。
如您所见,x轴混乱。
我的问题是,是什么导致了这种情况?还有其他设置x轴范围的方法吗?
谢谢您的帮助。
英文:
I have the following data:
100 100.0
500 499.8
1000 999.0
2000 1994.4
3000 2918.8
10000 8233.8
99999 9433.2
I want to plot this so I have all x-axis labels equally spaced. Taking this link into account, I made the following script:
set terminal png size 500,500
set output 'throughput.png'
set title 'Connection throughput'
plot 'throughput.txt' using 0:2:xticlabel(1) title "Throughput"
I get the following.
Nonetheless, I want the data points from 100 and 99999 values to be visible. To solve it I tried using the set xrange [0,110000]
instruction. The result this.
As you can see, x-axis is messed up.
My questions are, what is causing this to happen? Is there any other way to set the x-axis range?
Thanks for any help in advance.
答案1
得分: 1
你的数据点从100到99999可见。这些紫色的“+”标志只是在坐标轴上方,几乎看不见。
两个可能的选择:
-
更改点类型和颜色以使数据点“可见”
-
在图表上添加偏移量(或边距)(参考
帮助 偏移
)
还有可能的选项:
设置偏移量 0.5,0.5,0.0,0.0
脚本:
### 更改点类型并添加边距
重置会话
$数据 <<EOD
100 100.0
500 499.8
1000 999.0
2000 1994.4
3000 2918.8
10000 8233.8
99999 9433.2
EOD
设置键左上
设置偏移量图形 0.05,图形 0.05,图形 0.05,图形 0.00 # 左、右、上、下
绘制 $数据 使用 0:2:xtic(1) w points pt 7 lc "red" ti "吞吐量"
### 脚本结束
结果:
英文:
Your data points from 100 and 99999 are visible. These violet +
s are just on top of the axes and hardly visible.
Two possible options:
-
change the pointtype and color to make the data points "visible"
-
add an offset (or margin) to your graph (check
help offsets
)
Also possible:
set offsets 0.5, 0.5, 0.0, 0.0
Script:
### change pointtype and add margins
reset session
$Data <<EOD
100 100.0
500 499.8
1000 999.0
2000 1994.4
3000 2918.8
10000 8233.8
99999 9433.2
EOD
set key top left
set offsets graph 0.05, graph 0.05, graph 0.05, graph 0.00 # left, right, top, bottom
plot $Data u 0:2:xtic(1) w points pt 7 lc "red" ti "Throughput"
### end of script
Result:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论