简体   繁体   English

Gnuplot没有绘制负值

[英]Gnuplot does not plot negative values

Data file bipdeutschland.csv: 数据文件bipdeutschland.csv:

1991    79.09   0
1992    80.61   1.9
1993    79.84   –1.0
1994    81.8    2.5
1995    83.19   1.7
1996    83.84   0.8
1997    85.37   1.8
1998    87.05   2
1999    88.78   2
2000    91.43   3
2001    92.98   1.7
2002    92.99   0
2003    92.32   –0.7
2004    93.41   1.2
2005    94.07   0.7
2006    97.56   3.7
2007    100.75  3.3
2008    101.81  1.1
2009    96.07   –5.6
2010    100.00  4.1
2011    103.59  3.6
2012    103.98  0.4
2013    104.09  0.1
2014    105.76  1.6

PLT file: PLT文件:

set xdata time
set timefmt "%Y"
set format x "%Y"
set format y "%6.0f"
set xrange ["1990":"2015"]
set yrange [0:120]
set style fill solid 1.0
set boxwidth 0.85 relative

set xlabel "Jahr"
set ylabel "Reales Bruttoinlandsprodukt (2010=100%)"

set y2range [-5:5]
set y2label "Veränderung des Bruttoinlandsprodukts zum Vorjahr (in %)"
set y2tics 2
set ytics nomirror
set xtics nomirror

set output "bipdeutschland.png"
set term png size 1000, 500
plot "bipdeutschland.csv" using 1:2 title '' w boxes lc rgb "green", "bipdeutschland.csv" using 1:3 title '' with lines lw 4 lc rgb "red" axes x1y2;

脚本的输出

The red line should be in the negative range for 1993, 2003 and 2009, but it clearly isn't. 红线应该在1993年,2003年和2009年的负范围内,但显然不是。 Where is the problem, does gnuplot fails to parse the input file or is my code wrong? 问题在哪里,gnuplot无法解析输入文件或我的代码是错误的吗?

Your data file is wrong. 您的数据文件错误。 If you look closely at your output you see, that the points with negative values are skipped. 如果仔细观察输出,则会跳过带有负值的点。

The problem is, that instead of having a minus sign (U+002D), you have an en-dash (U+2013), so that gnuplot fails to parse the negative numbers, since the aren't numbers. 问题是,没有减号 (U + 002D),你有一个en-dash (U + 2013),因此gnuplot无法解析负数,因为它们不是数字。

Using the following, corrected data file 使用以下更正的数据文件

1991    79.09   0
1992    80.61   1.9
1993    79.84   -1.0
1994    81.8    2.5
1995    83.19   1.7
1996    83.84   0.8
1997    85.37   1.8
1998    87.05   2
1999    88.78   2
2000    91.43   3
2001    92.98   1.7
2002    92.99   0
2003    92.32   -0.7
2004    93.41   1.2
2005    94.07   0.7
2006    97.56   3.7
2007    100.75  3.3
2008    101.81  1.1
2009    96.07   -5.6
2010    100.00  4.1
2011    103.59  3.6
2012    103.98  0.4
2013    104.09  0.1
2014    105.76  1.6

does also give the correct output using your script: 还使用您的脚本提供正确的输出:

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM