Gnuplot:使用统计输出作为数据点 [英] Gnuplot : Using a stats output as a data point

查看:46
本文介绍了Gnuplot:使用统计输出作为数据点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有三个带有矩阵的数据文件;我使用统计信息在矩阵中找到每个文件的最大值,并且可以正确显示.我需要使用这三个最大值作为数据点并对其进行绘图,以使我的绘图上的点为(1.0,A_max),(2.0,B_max)和(3.0,C_max),其中A_max是使用从第一个数据文件,第二个为B_max,第三个为C_max.这是我的gp文件的样子:

I have three data files each with a matrix; I use stats to find the maximum value in the matrix for each file and it is displayed correctly. I need to use those three maximum values as data points and plot them so as to have points on my plot as (1.0, A_max), (2.0, B_max) and (3.0, C_max) where A_max is the maximum value calculated using stats from first data file, B_max from second and C_max from third. Here is how my gp file looks like :

    set terminal epslatex size 3.5,2.62 color colortext
    set output 'data.tex'
    set xlabel '$x$'
    set ylabel '$y$'

    stats 'dataA.txt' matrix name "A"
    show variables A_
    stats 'dataB.txt' matrix name "B"
    show variables B_
    stats 'dataC.txt' matrix name "C"
    show variables C_

    plot '-' w p, '-' w p, '-' w p
    1.0 A_max
    e   
    2.0 B_max
    e
    3.0 C_max
    e

我得到的情节如下图.

很显然,它以x轴为0,而我打算用于x轴的点对应于y.不知道我缺少什么,可能是如何读取stats变量.任何帮助将不胜感激.

Clearly, it is taking x-axis as 0 and the points I intend for my x-axis corresponding to y. Not sure what I am missing, probably how to read the stats variable. Any help will be appreciated.

推荐答案

内联数据与您正在使用的一样,按原样使用,无需任何变量替换.使用 set print $ data 将数据打印到命名数据块 $ data :

Inline data, like you are using, is used as-is without any variable replacement. Use set print $data to print data to the named data block $data:

set print $data
stats 'dataA.txt' matrix name "A"
print sprintf("%e A", A_max)
stats 'dataB.txt' matrix name "B"
print sprintf("%e B", B_max)
stats 'dataC.txt' matrix name "C"
print sprintf("%e C", C_max)
plot $data using 0:1:xticlabel(2) w p notitle

或者,具有更多自动化功能:

or, with more automation:

set print $data
do for [f in "A B C"]{
    stats 'data'.f.'.txt' matrix name f
    print sprintf("%e %s", value(f.'_max), f)
}
plot $data using 0:1:xticlabel(2) w p notitle

这篇关于Gnuplot:使用统计输出作为数据点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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