首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Gnuplot plot Matrix over Matrix

Gnuplot plot Matrix over Matrix
EN

Stack Overflow用户
提问于 2016-11-08 23:10:06
回答 1查看 78关注 0票数 0

我有一个文件,里面有很多矩阵。

代码语言:javascript
复制
y [m]
0.000000e+00    1.751220e-04    3.499253e-04    5.240956e-04    6.974406e-04
8.698938e-04    1.041423e-03    1.211997e-03    1.381576e-03    1.550104e-03
1.717548e-03    1.883899e-03    2.049140e-03    2.213239e-03    2.376164e-03
2.537870e-03    2.698285e-03    2.857244e-03    3.014375e-03    3.168647e-03

temperature [K]
2.981500e+02    2.981482e+02    2.981463e+02    2.981445e+02    2.981426e+02
2.981407e+02    2.981388e+02    2.981368e+02    2.981349e+02    2.981328e+02
2.981308e+02    2.981286e+02    2.981264e+02    2.981241e+02    2.981218e+02
2.981192e+02    2.981166e+02    2.981138e+02    2.981108e+02    2.981075e+02

我想画出y的温度。我怎么用gnuplot来做呢?

EN

回答 1

Stack Overflow用户

发布于 2020-08-22 05:02:55

对于这一点,一个可能的gnuplot "hack“是这样的(笨拙但不太难看)。适用于gnuplot 5.0 (问题时的版本)。不确定字符串Mat1Mat2是否有长度限制或长度限制是多少。

数据:

代码语言:javascript
复制
# TestMatrix1.dat
# temperature [K]
2.981500e+02    2.981482e+02    2.981463e+02    2.981445e+02    2.981426e+02
2.981407e+02    2.981388e+02    2.981368e+02    2.981349e+02    2.981328e+02
2.981308e+02    2.981286e+02    2.981264e+02    2.981241e+02    2.981218e+02
2.981192e+02    2.981166e+02    2.981138e+02    2.981108e+02    2.981075e+02

代码语言:javascript
复制
# TestMatrix2.dat
# y [m]
0.000000e+00    1.751220e-04    3.499253e-04    5.240956e-04    6.974406e-04
8.698938e-04    1.041423e-03    1.211997e-03    1.381576e-03    1.550104e-03
1.717548e-03    1.883899e-03    2.049140e-03    2.213239e-03    2.376164e-03
2.537870e-03    2.698285e-03    2.857244e-03    3.014375e-03    3.168647e-03

代码:

代码语言:javascript
复制
### plot one matrix vs. another matrix
reset session

FILE1 = "TestMatrix1.dat"
FILE2 = "TestMatrix2.dat"
stats FILE1 nooutput
ColMax = STATS_columns    # get maximum number of columns

set table $Dummy
    Mat1 = Mat2 = ''
    plot for [i=1:ColMax] FILE1 u (Mat1=Mat1.sprintf(" %g",column(i)),0) w table
    plot for [i=1:ColMax] FILE2 u (Mat2=Mat2.sprintf(" %g",column(i)),0) w table
unset table

set print $Data
    do for [i=1:words(Mat1)] {
        print sprintf("%s %s",word(Mat1,i),word(Mat2,i))
    }
set print

plot $Data u 1:2 w p pt 7

### end of file

结果:

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40490348

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档