gnuplot切除小数位数 [英] gnuplot cuts off fractional digits

查看:112
本文介绍了gnuplot切除小数位数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想绘制一些库存数据.
数据位于一个csv文件中,我已经得到了几乎准确的绘图,因此从文件中读取并不是问题.

I want to plot some stockpile data.
The data is located in a csv-file and I already got an almost accurate plot, so reading from file isn't the problem.

set terminal pdf
set output "gnuplot/".MATNUM."-2012.pdf"

set datafile separator ";"

stats 'Stock-2012.csv' every ::4::18 using MATNUM nooutput

set border 3
set tics nomirror
set xzeroaxis

set xrange[0:14]
set xtics 1,1,13
set xtics rotate 90

set ylabel MATUNIT

maxplot = sprintf("Amount max:\n%.2f ".MATUNIT, STATS_max)
plot 'Stock-2012.csv' every ::4::18 using ($0+1):MATNUM:xticlabels(2) with linespoints title "Amount", STATS_max with lines lc rgb 'blue' title maxplot

其中MATNUM和MATUNIT是命令行参数,代表物料编号(数据文件中的列标题)和物料的测量单位.

Where MATNUM and MATUNIT are commandline arguments, representing materialnumber (which is the columntitle in the datafile) and the unit in which the material is measured.

我的数据文件中的x值是小数,但是gnuplot似乎切断了小数位数.例如,12,98(逗号作为小数点分隔符,因为它是德国库存)用作数据点,其y = 12.
我不确定,但是我认为这只会在最大和最小y值处发生,因为STATS_max每次都是整数.

The x-values in my datafile are decimals, but gnuplot seems to cut off the fractional digits. For example 12,98 (commata are used as decimal separator, because it's a german stockpile) results in a datapoint at y=12.
I'm not sure but I think this happens only at the maximum and minimum y-value, as STATS_max is an integer every time.

我该怎么做才能使点达到正确的y值?

What can I do to get my points at the right y-value?

推荐答案

很遗憾,您没有显示文件中的任何数据,但是我想您使用逗号作为小数点分隔符.在这种情况下,您需要设置正确的十进制符号以读取输入.您可以使用例如

Unfortunately you did not show any data from you file, but I guess you are using commas as decimal separators. In that case you need to set the right decimal sign for reading the input. You can use e.g.

set decimalsign locale

或使用显式语言环境(必须已安装)

or use an explicit locale (this must be installed)

set decimalsign locale "de_DE.UTF-8"

请注意,用set decimalsign ','设置显式字符是行不通的,因为它通常仅影响例如的输出格式.抽动,而不是输入行为.

Note, that setting an explicit character with set decimalsign ',' does not work because it usually affects only the output format of e.g. tics, but not the input behaviour.

这篇关于gnuplot切除小数位数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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