【问题标题】:Stacked auto-binned histograms in gnuplotgnuplot 中的堆叠自动分箱直方图
【发布时间】:2016-02-25 14:55:43
【问题描述】:

ways to have gnuplot bin your data for you围绕

binwidth=5
bin(x,width)=width*floor(x/width)

plot 'datafile' using (bin($1,binwidth)):(1.0) smooth freq with boxes

还有ways to plot stacked histograms from pre-binned data,使用

set style data histogram
set style histogram rowstacked

plot 'test.dat' using 2:xtic(1) title 'Col1', '' using 3 title 'Col2'

有没有办法两全其美?我可以

plot 'a.dat' using (bin($1,binwidth)):(1.0) smooth freq with boxes lc 'red' ,\
     'b.dat' using (bin($1,binwidth)):(1.0) smooth freq with boxes lc 'blue' 

但如果我set style fill solid 第一个情节被画了出来。

【问题讨论】:

    标签: gnuplot histogram binning


    【解决方案1】:

    您可以将平滑后的数据写入外部文件,然后将此临时文件绘制为直方图:

    binwidth=5
    bin(x,width)=width*floor(x/width)
    
    set table 'temp.dat'
    plot 'a.dat' using (bin($1,binwidth)):(1.0) smooth freq, \
      'b.dat' using (bin($1,binwidth)) smooth freq
    unset table
    
    set style data histogram
    set style histogram rowstacked
    
    plot 'temp.dat' using 2:xtic(1) index 0 title 'a.dat', '' using 2 index 1 title 'b.dat'
    

    a.datb.dat 的两个平滑图都保存在文件temp.dat 中,由两个空行分隔。因此,可以使用index 选项访问它们以进行绘图。

    【讨论】:

      猜你喜欢
      • 2016-12-19
      • 1970-01-01
      • 2012-06-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-01
      • 2016-02-07
      • 1970-01-01
      相关资源
      最近更新 更多