Gnuplot图矩阵对矩阵 [英] Gnuplot plot Matrix over Matrix
本文介绍了Gnuplot图矩阵对矩阵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含大量矩阵的文件.
I have a file which has lots of matrizes.
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?
I want to plot temperature of y. How can i do it using gnuplot?
推荐答案
一种可能的gnuplot"hack";因为这将是以下内容(笨拙但不太难看).
适用于gnuplot 5.0(在提出问题时为版本).不知道字符串Mat1
和Mat2
是否存在长度限制,或者是什么长度限制.
One possible gnuplot "hack" for this would be the following (awkward but not too ugly).
Works for gnuplot 5.0 (version at the time of the question). Not sure, if there is or what is the length limit for the strings Mat1
and Mat2
.
数据:
# 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
和
# 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
代码:
### 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
结果:
这篇关于Gnuplot图矩阵对矩阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文