i have a text of x,y,z points with which i want to draw a 3d surface plot. The code that calculates these points, however, sometimes gives coordinates of zero value (0.000000000000000000e+00 to be precise). I have tried to ignore them using
set datafile missing '0.000000000000000000e+00'.
The result is that the surface plot continues towards the (0,0,0) point. In the case of non-zero values, the plot appears to be working fine. Here is the gnuplot script i am currently using:
set title "Thermal efficiency versus maximum cycle pressure and expander inlet temperature"
set grid
set key top left
#set key off
set view 60,60
set xlabel "phigh [MPa]"
set ylabel "T3 [oC]"
set zlabel "nth [-]"
#set xrange[0.0:0.0]
#set yrange[0.0:0.0]
#set zrange[0.0:0.0]
set datafile missing '0.000000000000000000e+00'
set dgrid3d 100,100
#set hidden3d
#set palette model CMY rgbformulae 7,5,15
set palette rgbformulae 33,13,10
#splot "performance_parameters.txt" using ($1/1000000.0):($2-273.15):($3) notitle with points palette pointsize 1 pointtype 7
splot "performance_parameters.txt" using ($1/1000000.0):($2-273.15):($3) notitle with lines palette
#splot "performance_parameters.txt" using ($1/1000000.0):($2-273.15):($3) notitle with points palette pointsize 1 pointtype 7
I would like to know if there is another way to skip the zero-coordinates lines.
example of working plot
Thank you in advance.
If I set datafile missing "0.000000000000000000e+00"
it works fine for me (gnuplot 5.2.8). I guess that the string has to exactly match the value as a string in your data. Well, another approach would be to define a functions which returns NaN
if the data value is 0
. So the left graph is including 0
and the other graphs do not include 0
.
Code:
### exclude data with 0 values
reset session
$Data <<EOD
1 1 0.1
1 2 0.3
1 3 0.2
2 1 0.5
2 2 1.3
2 3 1.2
0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00
3 2 0.9
3 3 0.7
EOD
set dgrid3d 20,20
myNonZero(col) = column(col) == 0 ? NaN : column(col)
unset colorbox
set multiplot layout 1,3
splot $Data u 1:2:3 w l palette
set datafile missing "0.000000000000000000e+00"
splot $Data u 1:2:3 w l palette
splot $Data u (myNonZero(1)):2:3 w l palette
unset multiplot
### end of code
Result:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.