set gnuplot precision for a specific column

谁说胖子不能爱 提交于 2019-12-12 02:25:29

问题


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 with image

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!


回答1:


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

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

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.



来源:https://stackoverflow.com/questions/22231375/set-gnuplot-precision-for-a-specific-column

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