Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
552 views
in Technique[技术] by (71.8m points)

gnuplot cuts off fractional digits

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:
%.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

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.

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.

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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"

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...