- gnuplot Cookbook
- Lee Phillips
- 289字
- 2021-08-20 15:42:54
Handling financial data
Although gnuplot was originally envisioned as a scientist's companion, it has proven to be a worthy and reliable friend to financial analysts. Financial plotting comes with its own set of complex problems, some of which we'll have to defer to later chapters; in the following figure, we illustrate the basic financial plotting style:

This type of plot will be familiar to you if you follow the stock market.
Getting ready
Sample financial data is essential for illustrating financial plotting. Fortunately, the gnuplot distribution comes with an appropriate sample datafile. In case you don't have it, we have provided a copy called finance.dat
. Make sure it's in your current directory so that gnuplot can find it. You are welcome, of course, to use your own data, but it must be in the correct format. Each line of the file represents a separate data point, and consists of (at least) five numbers, separated by spaces: date open low high close
.
An example of a line from such a datafile would look similar to the following:
3/11/2011 76.15 76.63 75.2 75.35
How to do it…
Enter the following commands while you are in the directory containing the datafile:
set bars 2 plot [0:100] 'finance.dat' using 0:2:3:4:5 notitle with financebars
How it works…
This makes the conventional financial graph showing the high, low, open, and close prices for a stock. If you are reading this recipe, you no doubt already know why you want this type of plot.
The default size of the tics for the opening and closing prices is quite small; the first command makes it longer. The second command sets the range, chooses the file, and specifies the columns to use for the finance plot.
- GitHub Essentials
- 數據庫技術與應用教程(Access)
- 從0到1:數據分析師養成寶典
- 揭秘云計算與大數據
- Enterprise Integration with WSO2 ESB
- 深入淺出MySQL:數據庫開發、優化與管理維護(第2版)
- 數據庫原理與應用(Oracle版)
- 數亦有道:Python數據科學指南
- 跟老男孩學Linux運維:MySQL入門與提高實踐
- ZeroMQ
- Python數據分析與挖掘實戰(第3版)
- Hadoop大數據開發案例教程與項目實戰(在線實驗+在線自測)
- HikariCP連接池實戰
- 深入理解InfluxDB:時序數據庫詳解與實踐
- Unreal Engine Virtual Reality Quick Start Guide