Gnuplot烛台和盒子宽度

时间:2014-06-06 23:53:36

标签: gnuplot financial candlestick-chart

正在使用烛台处理实际财务数据。除非我的数据存在空白,否则它的效果会非常好,因为有大量的历史财务数据。

我已经“设置了盒子宽度1相对”并且它工作正常,它在大多数情况下为我提供了烛台的正确“宽度”。但如果2点之间没有数据,烛台将变得更胖,即它向右延伸以填补该间隙。视觉是可怕的,右边的扩展非常糟糕。

我尝试使用set boxwidth x absolute进行游戏,但我无法明确它的显示方式。我把它缩小到set boxwidth 37500 absolute,并且不知道为什么这个数字有效,即使它有更糟糕的问题,然后设置的盒宽1相对。

第一张图片是使用set boxwidth 37500 absolute的样子。那里的日期是从2013年1月31日,02/01/13,02/03/13,02/04/13,02/05/13。没有02/02/13:

enter image description here

绝对显示02/01和02/02之间的适当差距,但02/03和02/04重叠,原因无法解释。

第二张图片使用set boxwidth 1 relative。这主要是我想要的方式。烛台相邻,大部分都是正确的。但是在02/02/13它的差距向右扩展。在02/09/13还有一个差距,它也会增加,或者可能两边的两个延伸以填补我不知道的差距。

enter image description here

如何配置此选项以使所有烛台相邻的宽度相等且数据中的间隙为空?

我用疯狂搜索了这个,没有人谈论它。我发现的烛台的几个例子不使用“日期”而是整数,完全没用。烛台图表需要手册的日期。

在Windows 7上运行Gnuplot 4.6 patchlevel 0。

谢谢

PS:我应该在这里添加数据。

basic.csv

2013-01-15 00:00:00,93.879000,93.949000,92.874000,93.078000
2013-01-16 00:00:00,93.079000,93.672000,92.458000,92.800000
2013-01-17 00:00:00,92.799000,95.011000,92.629000,94.616000
2013-01-18 00:00:00,94.617000,94.872000,94.157000,94.662000
2013-01-20 17:00:00,94.649000,94.820000,93.965000,94.155000
2013-01-21 00:00:00,94.159000,94.938000,93.726000,94.009000
2013-01-22 00:00:00,94.011000,94.284000,93.147000,93.231000
2013-01-23 00:00:00,93.229000,94.024000,92.793000,93.649000
2013-01-24 00:00:00,93.650000,94.715000,93.559000,94.489000
2013-01-25 00:00:00,94.490000,95.083000,94.472000,94.749000
2013-01-27 17:00:00,94.819000,95.007000,94.652000,94.834000
2013-01-28 00:00:00,94.835000,94.968000,94.082000,94.809000
2013-01-29 00:00:00,94.803000,95.330000,94.370000,95.248000
2013-01-30 00:00:00,95.245000,95.450000,94.255000,94.365000
2013-01-31 00:00:00,94.372000,95.799000,94.328000,95.714000
2013-02-01 00:00:00,95.715000,96.718000,95.457000,96.597000
2013-02-03 17:00:00,96.716000,96.777000,96.370000,96.572000
2013-02-04 00:00:00,96.574000,97.064000,95.968000,96.044000
2013-02-05 00:00:00,96.043000,97.426000,95.945000,97.131000
2013-02-06 00:00:00,97.133000,97.284000,96.092000,96.395000
2013-02-07 00:00:00,96.396000,97.023000,95.813000,96.145000
2013-02-08 00:00:00,96.146000,96.182000,95.124000,95.625000
2013-02-10 17:00:00,95.623000,95.744000,95.210000,95.339000
2013-02-11 00:00:00,95.336000,96.877000,95.168000,96.537000
2013-02-12 00:00:00,96.536000,96.719000,95.776000,96.214000
2013-02-13 00:00:00,96.216000,96.890000,96.114000,96.775000
2013-02-14 00:00:00,96.771000,96.964000,95.609000,95.621000
2013-02-15 00:00:00,95.622000,96.676000,95.521000,96.351000

absolute.plt

reset

set border linecolor rgbcolor "yellow"
set key textcolor rgbcolor "white"

set obj 1 rectangle behind from screen 0,0 to screen 1,1
set obj 1 fillstyle solid 1.0 fillcolor rgbcolor "black"

set xdata time
set timefmt"%Y-%m-%d %H:%M:%S"
set xrange ["2013-01-15 00:00:00":"2013-02-15 23:59:59"]

set yrange [*:*]
set datafile separator ","

set palette defined (-1 'red', 1 'green')
set cbrange [-1:1]
unset colorbox

set style fill solid noborder
set boxwidth 37500 absolute

set title "AUDJPY" textcolor rgbcolor "white"
plot 'basic.csv' using 1:2:4:3:5:($5 < $2 ? -1 : 1) with candlesticks palette

relative.plt

reset

set border linecolor rgbcolor "yellow"
set key textcolor rgbcolor "white"

set obj 1 rectangle behind from screen 0,0 to screen 1,1
set obj 1 fillstyle solid 1.0 fillcolor rgbcolor "black"

set xdata time
set timefmt"%Y-%m-%d %H:%M:%S"
set xrange ["2013-01-15 00:00:00":"2013-02-15 23:59:59"]

set yrange [*:*]
set datafile separator ","

set palette defined (-1 'red', 1 'green')
set cbrange [-1:1]
unset colorbox

set style fill solid noborder
set boxwidth 1 relative

set title "AUDJPY" textcolor rgbcolor "white"
plot 'basic.csv' using 1:2:4:3:5:($5 < $2 ? -1 : 1) with candlesticks palette

1 个答案:

答案 0 :(得分:4)

使用set boxwidth absolute时,宽度以x轴为单位给出,在日期的情况下为秒。因此,37500的宽度为10小时。

您还可以在第6列中使用显式宽度,并切换到-2以获取某些列的自动框宽度。但是,这需要您手动操作数据文件。

另一点:您是否必须在某些数据点中包含小时数?这是缩小一些相邻点的距离的原因。你可以忽略小时,这会给你一个最小一天的点距离。要删除小时数,请在strptime语句中使用using

reset

set border linecolor rgbcolor "yellow"
set key textcolor rgbcolor "white"

set obj 1 rectangle behind from screen 0,0 to screen 1,1
set obj 1 fillstyle solid 1.0 fillcolor rgbcolor "black"

set xdata time
set timefmt"%Y-%m-%d %H:%M:%S"
set xrange ["2013-01-15 00:00:00":"2013-02-15 23:59:59"]

set yrange [*:*]
set datafile separator ","

set palette defined (-1 'red', 1 'green')
set cbrange [-1:1]
unset colorbox

set style fill solid noborder
set boxwidth 60000 absolute

set title "AUDJPY" textcolor rgbcolor "white"
plot 'basic.csv' using (strptime('%Y-%m-%d', strcol(1))):2:4:3:5:($5 < $2 ? -1 : 1) with candlesticks palette

4.6.0的结果:

enter image description here