2016-04-21 111 views
0

我有.dat文件中的日期和值,我試圖繪製一個圖形。我已經實現繪製條形圖,但是該圖形不完全適合邊界Gnuplot條形圖對齊

數據在「.DAT」文件

2016年4月21日12804662
2016年4月20日12294895
2016年4月19日12629974
2016年4月18日10775333
2016年4月17日10499770

下面是gnupot腳本

/usr/bin/gnuplot <<\__EOF 

set terminal pngcairo size 900, 300 
set output "chart_1.png" 
set grid 
set tics font ", 10" 
set boxwidth 10000 
set style fill solid 
set format y "" 
set xtics rotate 
set xdata time 
set timefmt "%Y-%m-%d" 
plot "DATA.dat" using 1:2:xtic(1) with boxes notitle lc rgb "blue", "" u 1:2:2 with labels notitle offset char 0,1 

__EOF 

下面是圖表。有人可以幫我將這張圖繪製在邊界上,看起來更合理嗎?

enter image description here

感謝

+0

這個請求任何幫助 – user3415790

+1

看看'設置xrange'和'設置yrange'。我相信,設置範圍是你需要做的所有事情(向雙方添加一點,向頂部添加一點)。 – Matthew

回答

1
  1. 調整你的輸出.png更薄的一個! (例如500x300)
  2. 使用更寬的酒吧! (如50000)
  3. 使用xrange/yrange

    plot [<xmin>:<xmax>][<ymin>:<ymax>] 
    
  4. 提高您的解決方案 '自我自動' 與GP_VAL -s,像波紋管代碼:

    set terminal pngcairo size 500, 300 
    set grid 
    set tics font ", 10" 
    set boxwidth 50000 
    set style fill solid 
    set format y "" 
    set xtics rotate 
    set xdata time 
    set timefmt "%Y-%m-%d" 
    set output "/dev/null" 
    plot "DATA.dat" using 1:2:xtic(1) with boxes notitle lc rgb "blue", "" u 1:2:2 with labels notitle offset char 0,1 
    plot[GPVAL_DATA_X_MIN-20000:GPVAL_DATA_X_MAX+20000][0:GPVAL_DATA_Y_MAX*1.25] "DATA.dat" using 1:2:xtic(1) with boxes notitle lc rgb "blue", "" u 1:2:2 with labels notitle offset char 0,1 
    set output "chart_1.png" 
    plot[GPVAL_DATA_X_MIN-20000:GPVAL_DATA_X_MAX+20000][0:GPVAL_DATA_Y_MAX*1.25] "DATA.dat" using 1:2:xtic(1) with boxes notitle lc rgb "blue", "" u 1:2:2 with labels notitle offset char 0,1 
    # exit with exit or EOF or... 
    

一兩個空白繪圖必須用數據文件中的正確值初始化GPVAL_X_MIN和其他值(任何時候它們在繪圖後更新)。


My output


+0

謝謝湯姆。它像一個魅力 – user3415790