Remove weekend gaps in gnuplot for candlestick chart

前端 未结 1 832
难免孤独
难免孤独 2021-01-14 06:02

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. Pict

1条回答
  •  离开以前
    2021-01-14 06:37

    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
    

    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
    

    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
    

    Results in:

    Candlestick graph with no weekend gaps

    0 讨论(0)
提交回复
热议问题