我的數據進行格式化,像這樣:與X繪製作爲時間範圍
2014-11-17 19 18
2014-11-18 8 20
2014-11-19 23 16
2014-11-20 28 20
等。
我gnuplot的腳本如下:
gnuplot -e "
set output 'commits-per-day-with.png';
set term png truecolor giant;
set xdata time;
set timefmt '%Y-%m-%d';
set format x '%Y-%m-%d';
set xrange ['$min_date':'$max_date'];
set xtics 7;
set grid y;
set boxwidth 1.0 relative;
set style fill transparent solid 0.5 noborder;
plot '$tmp_file' using 0:2 with boxes title 'authored',
'' using 0:3 with boxes title 'committed';
"
它嵌入到一個shell腳本,你可以看到。 $min_date
和$max_date
變量的格式如下:2014-01-01
,就像數據中的格式(它實際上是從數據中取出的)和指定的格式一樣。
$tmp_file
當然是包含數據的文件。
gnuplot的告訴我:
line 0: all points y value undefined!
什麼是我的錯誤?
你的$ tmp_file有什麼問題嗎?在我的平臺上(Ubuntu 12.04上的gnuplot版本4.6補丁級別6)看起來沒問題,除了我使用默認的wxt終端並且沒有設置xrange。它確實產生了一個圖。順便說一句,爲什麼你用'使用0:2'而不是'使用1:2'進行繪圖呢? – DragonHu 2014-12-04 01:52:12
我不是一個gnuplot專家,我和一個有gnuplot經驗的朋友一起砍了這個,但是不知道如何正確地做到這一點...... – musicmatze 2014-12-04 15:28:44
但是使用'1使用1 :2'像@DragonHu建議... – Christoph 2014-12-04 17:57:11