gnuplot烛台红色和绿色填充 [英] gnuplot candlestick red and green fill

查看:172
本文介绍了gnuplot烛台红色和绿色填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

至少在我所见过的金融站点上,有烛台图,如果收盘价高于开盘价,则以绿色填充烛台;如果收盘价低于开盘价,则以红色填充烛台。

Candlestick plots on the financial sites, at least the ones I have seen, fill the candlestick green if the close is higher then the open, and red if the close is lower then the open.

如果我设置填充样式,所有烛台都填充有填充颜色,那么gnuplot 4.6中是否可以使用如上所述的配色方案?

If I set the fill style all candlesticks are filled with the fill color, is there a way in gnuplot 4.6 to use the color scheme as I described above?

一个示例脚本为:

set xdata time
set timefmt"%Y-%m-%d %H:%M:%S"
set xrange ["2014-01-01":"2014-01-02"]
set yrange [*:*]
set datafile separator ","
plot '201401_EURUSD_Hourly.csv' using 1:2:4:3:5 notitle with candlesticks


$使用$ 1 $ 2绘制图'201401_EURUSD_Hourly.csv' b $ b

有一些数据点

with some data points

2014-01-01 17:00:00,1.376150,1.376550,1.374020,1.375990
2014-01-01 18:00:00,1.376100,1.377340,1.375980,1.376520 
2014-01-01 19:00:00,1.376440,1.376870,1.375780,1.375860 
2014-01-01 20:00:00,1.375850,1.376470,1.375000,1.376280 
2014-01-01 21:00:00,1.376270,1.376720,1.375970,1.376530 
2014-01-01 22:00:00,1.376550,1.377440,1.376270,1.376530 
2014-01-01 23:00:00,1.376540,1.376540,1.374390,1.374520 
2014-01-02 00:00:00,1.374500,1.375790,1.374380,1.375660 
2014-01-02 01:00:00,1.375630,1.375740,1.374610,1.375000 
2014-01-02 02:00:00,1.374980,1.375270,1.372480,1.373100


推荐答案

以下是使用预定义调色板选择颜色(关键字调色板)的示例:

Here is an example which uses a predefined color palette to select the colors (keyword palette):

set xdata time
set timefmt"%Y-%m-%d %H:%M:%S"
set datafile separator ","

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

set style fill solid noborder

plot '201404_EURUSD_Hourly.csv' using 1:2:4:3:5:($5 < $2 ? -1 : 1)  notitle with candlesticks palette

使用另一列(最后一个)进行选择值 -1 (红色,收盘价低于开盘价)和 +1 (绿色,收盘价高于开盘价)之间。

That uses an additional column (the last one) to select between values -1 (red, close lower than open) and +1 (green, close higher than open).

4.6.4的输出为:

The output with 4.6.4 is:

第二个选项是使用 linecolor rgb变量,在这种情况下,最后一列必须以rgb-tuple的整数表示:

The second option is to use linecolor rgb variable, in which case the last column must be in integer representation of an rgb-tuple:

set xdata time
set timefmt"%Y-%m-%d %H:%M:%S"
set datafile separator ","

set style fill solid noborder

# Place colored points in 3D at the x,y,z coordinates corresponding to
# their red, green, and blue components
rgb(r,g,b) = 65536 * int(r) + 256 * int(g) + int(b)

plot '201404_EURUSD_Hourly.csv' using 1:2:4:3:5:($5 < $2 ? rgb(255,0,0) : rgb(0,255,0))  linecolor rgb variable notitle with candlesticks

最后但并非最不重要的是,使用 linecolor变量在两种线型之间进行选择(最后一列是线型索引):

And, last but not least, use linecolor variable to select between two linetypes (the last column is the linetype index):

set xdata time
set timefmt"%Y-%m-%d %H:%M:%S"
set datafile separator ","

set style fill solid noborder

set linetype 1 lc rgb 'red'
set linetype 2 lc rgb 'green'

plot '201404_EURUSD_Hourly.csv' using 1:2:4:3:5:($5 < $2 ? 1 : 2)  linecolor variable notitle with candlesticks

这篇关于gnuplot烛台红色和绿色填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆