消除gnuplot中烛台图的周末缺口 [英] Remove weekend gaps in gnuplot for candlestick chart
问题描述
我正在尝试使用gnuplot绘制一些金融烛台图。问题是周末没有数据,我不希望显示这些差距。
I am trying to plot some financial candlestick charts with gnuplot. The problem is that there is no data during the weekends, and I don't want these gaps to be showed. Picture and code included below.
set datafile separator ","
set xdata time
set timefmt"%Y-%m-%d"
set xrange ["2015-10-22":"2016-02-06"]
set yrange [*:*]
set format x
plot 'head.dat' using 1:2:4:3:5 notitle with candlesticks
推荐答案
因为每个工作日只有一个条目,而不是使用日期作为横坐标,您可以使用行号:
As you have one entry per working day, instead of using the dates as abscissae you can use the line number:
plot 'head.dat' using 0:2:4:3:5 notitle with candlesticks
然后,我想您会问如何恢复<$上的日期c $ c> x 轴。您可以使用 xticslabel
:
Then I guess you'll ask how to restore the dates on the x
-axis. You can use xticslabel
:
set xtics rotate 90
plot "head.dat" u 0:2:4:3:5:xticlabels(1) notitle with candlesticks
如果要避免显示每个标签,请使用此 everyNth
函数由 dir 发布,例如每五个标签:
If you want to avoid having every label shown use this everyNth
function posted by dir, e.g. every fifth label:
set datafile separator ","
everyNth(countColumn, labelColumnNum, N) = \
( (int(column(countColumn)) % N == 0) ? stringcolumn(labelColumnNum) : "" )
set xtics rotate 90
plot "head.dat" using 0:2:4:3:5:xticlabels(everyNth(0, 1, 5)) notitle with candlesticks
结果在:
这篇关于消除gnuplot中烛台图的周末缺口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!