为特定列设置gnuplot精度 [英] set gnuplot precision for a specific column

查看:120
本文介绍了为特定列设置gnuplot精度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含3列的数据文件,我想绘制2D地图.我在gnuplot中所做的是:

I have a data file with 3 columns and I'd like to plot a 2D map plot. What I do in gnuplot is:

p'datafile'u 1:2:3含图片

p'datafile' u 1:2:3 with image

对于某些数据集,第3列(例如Z)上的数据以0.01的顺序不同,例如1.56、1.58、1.59等.我想跳过这些小的差异并将它们全部考虑为1.5.如何将gnuplot设置为在第三列的小数点后最多只能考虑一位数字?谢谢!

for some set of data, the data on the 3rd column (say Z) are different with order of 0.01, e.g 1.56, 1.58, 1.59 etc. I'd like to skip those small difference and consider them all 1.5. How can I set gnuplot to consider only up to one digit after decimal for 3rd column? Thanks!

推荐答案

您可以使用floor函数将数字四舍五入:

You can use the floor function to round your numbers down:

plot 'datafile' using 1:2:(floor($3*1e1)/1e1) with image

这会将您的所有数字设置为小数点后一位.如果要对更多的小数位数执行相同的操作,则可以将1e1更改为1eN,其中N是所需的小数位数.

This sets all your numbers to 1 decimal place. If you wanted to do the same thing for a higher number of decimal places, you could change the 1e1 to 1eN, where N is the number of decimal places you want.

这篇关于为特定列设置gnuplot精度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆