【问题标题】:Gnuplot 3d surface plotGnuplot 3d 曲面图
【发布时间】:2020-10-16 17:25:19
【问题描述】:

我有一个 x,y,z 点的文本,我想用它来绘制 3d 曲面图。 然而,计算这些点的代码有时会给出零值的坐标(准确地说是 0.000000000000000000e+00)。 我试图忽略它们使用

set datafile missing '0.000000000000000000e+00'. 

结果是曲面图继续朝向 (0,0,0) 点。 在非零值的情况下,绘图似乎工作正常。 这是我目前使用的 gnuplot 脚本:

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

我想知道是否有另一种方法可以跳过零坐标线。

工作图示例

中断情节的例子

提前谢谢你。

【问题讨论】:

    标签: 3d gnuplot surface


    【解决方案1】:

    如果我 set datafile missing "0.000000000000000000e+00" 它对我来说很好(gnuplot 5.2.8)。 我猜该字符串必须与数据中的字符串值完全匹配。 好吧,另一种方法是定义一个函数,如果数据值为0,则返回NaN。所以左图包括0,其他图不包括0

    代码:

    ### 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
    

    结果:

    【讨论】:

    • 对于延迟回复,我深表歉意。似乎缺少的命令集数据文件不像我想象的那样工作。它排除算术运算后的点。例如,它读取的不是 0 的 $2,而是非零的 $2-273.15。因此,它考虑了各个点。现在的问题是我应该如何对所有三个坐标进行约束,即 x>0、y>0、z>0。无论如何,您的帖子为我指明了正确的方向。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多