Jen*_*en 3 gnuplot candlestick-chart
我试图用gnuplot绘制一些金融烛台图表.问题是周末没有数据,我不希望显示这些差距.图片和代码包含在下面.
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
Run Code Online (Sandbox Code Playgroud)
由于您每个工作日有一个条目,而不是使用日期作为横坐标,您可以使用行号:
plot 'head.dat' using 0:2:4:3:5 notitle with candlesticks
Run Code Online (Sandbox Code Playgroud)
然后我想你会问如何在x-axis 上恢复日期.你可以使用xticslabel:
set xtics rotate 90
plot "head.dat" u 0:2:4:3:5:xticlabels(1) notitle with candlesticks
Run Code Online (Sandbox Code Playgroud)
如果您想避免显示每个标签,请使用dir发布的此everyNth功能,例如每五个标签:
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
Run Code Online (Sandbox Code Playgroud)
结果是:
