gnuplot "stats"命令意外的 min & "out of range"结果

标签 gnuplot histogram

我正在尝试开发直方图脚本。情节本身似乎是正确的,但我有一些问题或疑问:

  • 我不明白为什么“统计”输出说我的数据文件有“超出范围”的点。这意味着什么?
  • “stats”最小值看起来也不正确。从数据文件中,最小值 = -0.0312,但 stats 报告为 0.0。

  • 剧本:
    # Gnuplot histogram from "Gnuplot In Action", 13.2.1 Jitter plots and histograms (p. 256)
    
    # these functions put data points (x) into bins of specified width
    bin(x,width)    = width*floor(x/width)
    
    binwidth = 0.01
    set boxwidth binwidth
    
    # data file
    data_file = "sorted.csv"
    png_file    = "sorted.png"
    datapoint_count = 14
    
    # taking explanations from the data file
    set style data linesp
    set key autotitle columnheader
    
    set datafile separator ","  # CSV format
    
    # histogram
    myTitle = "Histogram from \n" . data_file
    set title myTitle
    set style fill solid 1.0
    set xlabel "Slack"
    set mxtics
    set ylabel "Count"
    set yrange [0:*] # min count is always 0
    
    set terminal png    # plot file format
    set output png_file # plot to file
    
    print "xrange="
    show xrange
    print "yrange="
    show yrange
    
    stats data_file using ($1)
    print "STATS_records=", STATS_records
    print "STATS_invalid=", STATS_invalid
    print "STATS_blank=", STATS_blank
    print "STATS_min=", STATS_min
    print "STATS_max=", STATS_max
    
    plot  data_file using (bin($1,binwidth)):(1) smooth frequency with boxes
    

    数据文件:
    slack
    -0.0312219
    -0.000245109
    -4.16338e-05
    -2.08616e-05
    -1.82986e-05
    8.31485e-06
    1.00136e-05
    1.23084e-05
    0
    0.000102907
    0.000123322
    0.000138402
    0.19044
    0.190441
    

    输出:
    gnuplot sorted.gp
    Could not find/open font when opening font "arial", using internal non-scalable font
    xrange=
    
            set xrange [ * : * ] noreverse nowriteback  # (currently [-10.0000:10.0000] )
    
    yrange=
    
            set yrange [ 0.00000 : * ] noreverse nowriteback  # (currently [:10.0000] )
    
    
    * FILE: 
      Records:      9
      Out of range: 5
      Invalid:      0
      Blank:        0
      Data Blocks:  1
    
    * COLUMN: 
      Mean:          0.0424
      Std Dev:       0.0792
      Sum:           0.3813
      Sum Sq.:       0.0725
    
      Minimum:       0.0000 [3]
      Maximum:       0.1904 [8]
      Quartile:      0.0000 
      Median:        0.0001 
      Quartile:      0.0001 
    
    STATS_records=9.0
    STATS_invalid=0.0
    STATS_blank=0.0
    STATS_min=0.0
    STATS_max=0.190441
    

    最佳答案

    如果你给 stats 单列命令,yrange用于从此列中选择范围。

    乍一看,这没有意义,但表现得像 plot命令只有一列,在这种情况下,这一列是 y 值,行号被选为 x 值。

    所以,只需移动 set yrange stats后面的部分命令。

    data_file = 'sorted.csv'
    stats data_file using 1
    show variables all
    set yrange [0:*]
    plot data_file ...
    

    关于gnuplot "stats"命令意外的 min & "out of range"结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24790519/

    相关文章:

    gnuplot - 在 Gnuplot 中导入字体 : strange result

    python - 如何在 python 中绘制悬挂根图?

    python - 按两个标准分组的直方图 [python]

    ubuntu - 使用 gnuplot 烛台移动数据

    Gnuplot xrange 不是一个真正的范围?

    linux - 如何在 gnuplot 中设置灵活的 xrange

    r - 存储来自 ggplot2 的直方图以供稍后检索

    matlab - matlab中两幅彩色图像的直方图匹配

    python - Seabornpairplot kde 对角线默认行为

    gnuplot:绘制来自标准输入的两个数据集