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
654 views
in Technique[技术] by (71.8m points)

localization - gnuplot: How to enable thousand separators (digit grouping)?

I'm on German Windows 8.1 64Bit with gnuplot 4.6.5, using the svg terminal. If I plot datafiles that have big numbers, like "one million", gnuplot does not print a digit grouping sign.

For example, if my datafile has values in the order of one million, I want the numbers at the y-axis be displayed as 1.000.000 (with . being the group sign, not the decimal sign!), but gnuplot gives me just 1000000.

The option set decimalsign locale just changes the decimal sign (separator between whole number and fractional part, like 1+1/2 = 1,5 with , being the decimal sign). But neither setting decimalsign nor not calling this command at all shows digit grouping signs in the plot. I only get ugly 1000000 or 1500000 instead of 1.000.000 or 1.500.000.

I also tried

set decimal locale
set format y "%'f"

which just gives me at all tics the label "%'f", instead of the numbers! Each tic has just "%'f", again and again. It just prints the format string as is into the plot and no numbers at all. The console output is decimal_sign in locale is , which is correct for german locale, so gnuplot recognizes it correctly. In my control panel of Windows the thousand separator is set correctly to . and the decimal sign to , too.

Setting tic by tic by hand is no option. I.e. set ytics add ('1.000.000' 1e6) for dozenz of dozenz tics is no option for me.

How do I automatically get thousand separators in gnuplot?

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

That seems not to work on Windows. From the gnuplot documentation

Internationalization (locale settings): Gnuplot uses the C runtime library routine setlocale() to control locale-specific formatting of input and output number, times, and date strings. The locales available, and the level of support for locale features such as "thousands’ grouping separator", depend on the internationalization support provided by your individual machine.

And judging from questions like How can I add a thousands separator to a double in C on Windows? Printing integers with thousands separators in Windows using C it is not possible since the apostrophe in the format string is a Unix specialty and not a C standard.

I think there is no workaround to get this working on Windows with autoscaling.

For the records: The following script works fine on Linux:

set format "%'.0f"
set xrange [0:1e6]
plot x

enter image description here


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

...