我刚刚来到Dan Stahlke的gnuplot C++ I/O接口,这使我免于"滚动自己".不幸的是,没有太多可能的例子,并且没有真正的文档.
我的C++项目中有以下数据类型:
struct Data
{
std::string datestr; // x axis value
float f1; // y axis series 1
float f2; // y axis series 2
float f3; // y axis series 3
};
typedef std::vector<Data> Dataset;
Run Code Online (Sandbox Code Playgroud)
我想从C++传递一个数据集变量,这样我就可以绘制数据(X轴上的日期,以及Y轴上的时间序列绘制的3个数字).
谁能告诉我如何将数据集变量从C++传递到gnuplot(使用Gnuplot-iostream接口)并使用传入的数据制作一个简单的图?
我正在寻找一种简单,特别快的可能性,将存储在文本文件中的二进制矩阵(仅由0和1组成)转换为某种情节.黑白位图完全符合我的可视化目的.我尝试使用gnuplot,但我认为gnuplot第一次还不够,因为我有很多数据(至少几十个MiB)并且内存消耗和处理时间很糟糕.
在搜索解决方案时,我主要发现与存储二进制(数据格式)的矩阵相关的内容以及在例如gnuplot中读取二进制数据格式的可能性.
你知道吗,可以将文本矩阵转换为位图的任何程序的快?我甚至考虑编写一个小C程序,但由于我无法估计创建位图有多难,因为我从来没有完成图像处理之前使用现有工具会很好,如果可能.
谢谢!
我曾经设置类似于这篇文章的背景颜色:如何更改gnuplot中的背景颜色?
但是,对于最新的(4.5)版本,我被告知这种颜色选择已经过时了.有谁知道如何做到这一点?我尝试使用"set terminal png size 640,296 background#000000",但我被告知#000000不是#RRGGBB形式的字符串
我不同意,但终端没有心情争辩.
编辑:要添加到下面提供的解决方案,我从来没有在GNUplot中找到它,而是使用imagemagick命令
convert the.png -fill black -opaque white the.png
Run Code Online (Sandbox Code Playgroud) 我有两个文件,其时间为x轴和一个值.我需要在一个图上叠加这两个.目前我尝试使用GNUplot,但在中间打了一针.这是一个示例文件
01:03:05 6
01:03:15 6
Run Code Online (Sandbox Code Playgroud)
和另一个文件
01:03:55 6
01:04:10 6
Run Code Online (Sandbox Code Playgroud)
我需要在一个图中绘制这两个文件(比如x标记和其他一些用于区分的符号).我不知道在GNUplot中是否可以这样做.目前我为每个文件创建了两个网格.但我需要在一个单一的情节中.这是我写的
set multiplot layout 1,2 # engage multiplot mode
set xdata time ## these three lines control how gnuplot
set timefmt '%H:%M:%S' ## reads and writes time-formatted data.
set format x '%H:%M:%S' ##
set xtics 05 # make time spacing of 2 minutes
plot 'AAA' u 1:2 # plot the first data set
plot 'BBB' u 1:2 # plot the second data set
unset multiplot
Run Code Online (Sandbox Code Playgroud)
任何熟悉GNUplot或任何其他工具(在linux中工作)的人都可以帮助我.
数据如下:
38 52.26
41 46.34
42 49.49
Run Code Online (Sandbox Code Playgroud)
使用smooth线条; 我可以在图表行中包含这些点而无需绘制两次吗?
现在我使用:
plot "foo.dat" using ($0):2 smooth csplines title "foo", \
'' using ($0):2 with points title ""
Run Code Online (Sandbox Code Playgroud)

扩展的简化数据集:
38 52.26
39 46.34
42 57.29
43 60.41
44 53.57
45 51.49
46 48.24
49 58.50
50 56.85
51 55.56
52 62.81
54 51.76
55 46.94
56 46.35
57 52.76
59 49.49
62 51.78
63 48.24
65 54.46
66 50.00
Run Code Online (Sandbox Code Playgroud) 我正在编写一个脚本,一次一个地从多个文件中绘制多个文件.我还想保存与数据文件对应的每个绘图的输出.我们如何为GNUPlot提供两个参数.例如:示例GNUPlot脚本
set xlabel "a"
set ylabel "b"
set zlabel "c"
set term postscript
set output "??" #'??' implies variable i.e. take file name from commandline
splot "??" with points,"??" with points #'??' implies variable i.e. take file name from commandline
Run Code Online (Sandbox Code Playgroud)
此脚本将由另一个生成所需文件名的shell脚本运行.
任何帮助赞赏.
我想从我想要使用gnuplot绘制的文件中添加基于时间的数据的偏移量.我可以很好地绘制数据,但是当我尝试添加基于时间的偏移时,图形为空.
目的是绘制彼此相邻的多个条形图,如此处所述,但是使用基于时间的数据:两个图表"带框"彼此相邻并带有gnuplot
数据文件:
00:00 7719
01:00 20957
02:00 15989
03:00 9711
04:00 1782
05:00 871
06:00 4820
07:00 860
08:00 873
09:00 848
10:00 879
11:00 726
12:00 944
13:00 924
14:00 996
15:00 806
16:00 848
17:00 967
18:00 2277
19:00 2668
20:00 32183
21:00 14414
22:00 20426
23:00 16140
Run Code Online (Sandbox Code Playgroud)
我试图使用此代码绘制数据:
set xdata time
set timefmt "%H:%S"
set format x "%H"
set style fill solid 0.6 border -1
set boxwidth 0.3 relative
plot ["00:00":"23:30"] 'data.dat' using ($1-0.3):2 with …Run Code Online (Sandbox Code Playgroud) 我想在顶部绘制xtics但没有其tic标签:
这就是我要的:

这是我试过的代码:
set xtics mirror;
set border 2+4;
plot x;
Run Code Online (Sandbox Code Playgroud)
这给了我:

如何修改脚本以获得我想要的内容?
我想将数据标签的背景设置为白色!所考虑的图是以下数据(gnuDC.dat)的数据图:
4 1570.96 1571
8 770.63 771
12 530.33 530
16 385.13 385
24 261.87 262
48 137.71 138
96 81.42 81
Run Code Online (Sandbox Code Playgroud)
plot命令显示为:
plot "gnuDC.dat" using 1:2 title "DC: GNU Fortran 4.7.2 + Open MPI 1.6.3" w p ls 1, \
"gnuDC.dat" using 1:2:3 with labels center offset 2.,0.7 font "Helvetica,14" tc ls 4 notitle, \
"gnuDC.dat" using 1:3 notitle smooth csplines ls 14
Run Code Online (Sandbox Code Playgroud)
看起来还可以,但是认为当背景为白色时,可以更好地阅读标签。有没有一种简单的方法可以一次为所有标签添加白色背景?
这是整个打印文件:
set terminal postscript eps size 14cm,10cm enhanced color \
font 'Helvetica,18' linewidth 2 …Run Code Online (Sandbox Code Playgroud) 我在gnuplot中绘制了很多图表.这些图表基于来自太阳能系统周围的传感器读数.
每个图表都需要通过输入类似的内容进行更新
load "solar
Run Code Online (Sandbox Code Playgroud)
太阳能是一个gnuplot程序,执行显示24 V(500Ah)电池组状况的图表并将其留在屏幕上,这样我就可以进行区域屏幕捕获以进行存储.
在这种特殊情况下,数字以2分钟为间隔.除非逆变器打开,否则它们以20秒的间隔进入.所以我最终只是输入那个命令,只是为了看看信号是多么干净.
所以问题是我是否需要在每次想要查看更新时继续告诉它加载程序.
我怎样才能让它自动生效?