2016-04-21 112 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