温馨提示:本文翻译自stackoverflow.com,查看原文请点击:其他 - Conditional ploting in Gnuplot using fortran 90
fortran gnuplot

其他 - 使用fortran 90在Gnuplot中进行条件绘图

发布于 2020-04-24 14:28:46

我有一个要使用fortran 90和Gnuplot绘制的桁架桥,但是如果相应的数组元素大于或小于零,则桁架元素应更改颜色

open(10,file='plot_2D.plt')
write(10,*) 'set title " truss"'
write(10,*) 'set xrange [0:300]'
write(10,*) 'set yrange [0:40]'
write(10,*) 'set xlabel "x [U]"'
write(10,*) 'set ylabel "y [U]"' 
write(10,*) 'set key noautotitle'        
write(10,*) 'plot "1.txt" if (x(1) > 0 ) {with line 7} else { with line lt 3 } '
write(10,*) 'pause -1 "Hit return to continue"'
close(10)   

当然,我有1.txt到222.txt,但我只是在这里放一个,因为这是重复的过程,
但是我没有得到任何阴谋,我的错误是什么?

查看更多

提问者
A.Almanla
被浏览
49
Ethan 2020-02-08 01:58

x(1) > 0由于没有定义函数x(),因此不清楚您的确切含义假设x(1)data value in column 1,则代替

write(10,*) 'plot "1.txt" if (x(1) > 0 ) {with line 7} else { with line lt 3 } '

正确的语法是

write(10,*) 'plot "1.txt" using 1:2:($1>0 ? 7 : 3) with lines linecolor variable'