当前位置:首页 > 数据库 > SQlite

linux – 使用gnuplot绘制sqlite数据库

我有一个sqlite数据库,其中包含以下格式的基本天气信息:

temp1 temp2 pressure humidity
22    23    1024     40
24    25    1027     45
25    26    1020     62
18    15    1019     80

如何使用gnuplot绘制这些数据?在绘制数据之前,我是否必须重新排列数据?

解决方法:

要从sqlite数据库中提取数据,可以使用sqlite3命令行工具即时提取数据.这是通过使用< gnuplot来完成的.它产生一个shell并使用给定shell命令的输出进行绘图.

plot '< sqlite3 myfile.db3 "SELECT temp1, temp2, pressure, humidity FROM myTable;"' using 0:1 title 'temp1',      '' using 0:2 title 'temp2'

这将为每个绘图提取所有四个字段(”重复先前的文件名/ shell命令).您还可以使用函数来格式化shell命令:

SqliteField(f) = '< sqlite3 myfile.db3 "SELECT '.f.' from myTable;"'
fields = 'temp1 temp2 pressure humidity'
plot for [f in fields] SqliteField(f) using 0:1 title f

【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!