How to group boxplot outliers in gnuplot

 ̄綄美尐妖づ 提交于 2019-12-01 00:56:11

There is not option to have this done automatically. Required steps to do this manually in gnuplot are:

(In the following I assume, that the data file data.dat has only a single column.)

  1. Analyze your data with stats to determine the boundaries for the outliers:

    stats 'data.dat' using 1
    range = 1.5 # (this is the default value of the `set style boxplot range` value)
    lower_limit = STATS_lo_quartile - range*(STATS_up_quartile - STATS_lo_quartile)
    upper_limit = STATS_up_quartile + range*(STATS_up_quartile - STATS_lo_quartile)
    
  2. Count only the outliers and write them to a temporary file

    set table 'tmp.dat'
    plot 'data.dat' using 1:($1 > upper_limit || $1 < lower_limit ? 1 : 0) smooth frequency
    unset table
    
  3. Plot the boxplot without the outliers, and the outliers with the labels plotting style:

    set style boxplot nooutliers
    plot 'data.dat' using (1):1 with boxplot,\
         'tmp.dat' using (1):($2 > 0 ? $1 : 1/0):(sprintf('(%d)', int($2))) with labels offset 1,0 left point pt 7
    

And this needs to be done for every single boxplot.

Disclaimer: This procedure should work basically, but having no example data I couldn't test it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!