【问题标题】:gnuplot: How to plot points over the bars of a clustered histogram?gnuplot:如何在聚集直方图的条形图上绘制点?
【发布时间】:2019-08-06 19:26:29
【问题描述】:

我正在使用histogram clustered 制作一些加速图。对于每个实例,我将使用 2、4、8、16 和 32 台计算机达到的加速进行分组。我还用一条线来表示“线性加速”。但是,对于每个实例/计算机,我还想在其顶部放置一个 point,以指示我正在比较我的加速比的值。

我尝试使用相同的策略来绘制框,但使用点代替。但是,这些点绘制在同一个地方,它们不遵守“集群”间距。

这是我正在使用的代码:


set yrange [0:105]
set grid ytics

set style line 1 lc rgb '#0e1111' lt 1 lw 2 pt -1 ps 1.0 
set xlabel "Instance" font "sans, 18"
set ylabel "Normalized Speedup (In %)" font "sans, 18"

set style histogram clustered

plot  for [COL=2:2] 'data.dat' using COL:xticlabels(1) title columnheade lc rgbcolor "black" lt -1 fs pattern 3,\
for [COL=3:3] 'data.dat' using COL:xticlabels(1) title columnheade lc rgbcolor "black" lt -1 fs pattern 1,\
"linear.t" t "Lin" with linespoints ls 1

数据示例

0   2   4   8   16  32
ta22    65.67   37.98   38.16   30.91   19.24 
ta23    73.69   45.59   48.59   44.20   34.19 

这就是我得到的。积分是我想要的。

有可能有这样的东西吗?它也可以像错误栏一样工作。但是,没有线,只有一个“最大值”。

谢谢大家!

【问题讨论】:

    标签: gnuplot histogram


    【解决方案1】:

    我无法运行您的代码。但是,根据你的形象,我理解你的问题。 为了绘制你想要的点,我创建了一个名为 points.dat 的文件。

    0   2   4   8   16  32
    ta22    75.67   47.98   48.16   40.91   29.24 
    ta23    83.69   55.59   58.59   54.20   44.19
    

    这就是your data + 10
    gnuplot 代码

    reset                                           # Restore the default settings
    set encoding utf8                               # Selects the character encoding
    set terminal pngcairo size 800,500              # Generates output in png
    set output 'histogram.png'                      # The filename
    set grid ytics ls -1 lc 'gray'                  # Grid lines ytics only
    set yrange [0:100]                              # Yrange 0 to 100 (% ?)
    set style data histograms                       # Type of data: histograms
    set style histogram clustered gap 1             # Type of histogram: clustered with gap 1
    set style fill transparent solid 1 border lt -1 # Style: fillstyle and border
    
    stats 'points.dat' skip 1 matrix nooutput       # Statistical summary with skip
                                                    # for header and without output 
    
    numRows = STATS_size_y              # Y size of matrix (rows)
    numCols = STATS_size_x              # X size of matrix (columns)
    
    array Value[numRows*(numCols-1)]    # Create an array based on size of data
    
    position = 0                        # Count to position on array
    
    # Loop for populate the array
    do for [i=1:numRows]{
        do for [j=2:numCols]{
            # Statistical summary (with skip for header) at each value and without output 
            stats 'points.dat' skip 1 u j every ::i-1::i-1 nooutput
            position = position + 1         # Increase the count of position
            Value[position] = STATS_min     # Define the array-value as result of statistical analysis
        }
    }
    
    # Mapping functions: 
    # i-cluster/rows (x-values),
    # j-column (y-values)
    # ignore the cluster name ($1)
    posX(i, j) = (i - 1) + 1.0*(j - numCols + 3)/numCols        # To X-values
    posY(i, j) = i == 1 ? Value[j] : Value[numCols - 1 + j]     # To Y-values
    
    # The plot itself as newhistogram and nested loops:
    # i-loop to bars and title as columnheade
    # j-loop to rows (x-values)
    # k-loop to columns (y-values)
    plot \
        newhistogram ,\
            for [i=2:numCols]\
                'data.dat' u i:xticlabels(1) ls i-1 title columnheade,\
            for [j=1:numRows] \
                for [k=1:numCols-1] \
                    '+' u (posX(j, k)):(posY(j, k)) w p pt 5 ps 0.75 lc 'black' notitle 
    
    

    生产

    【讨论】:

    • 你好 GRSousaJr!谢谢!我尝试过并且工作得很好 =)))
    • 太棒了!不要忘记将您的问题标记为已回答。
    猜你喜欢
    • 1970-01-01
    • 2011-07-05
    • 1970-01-01
    • 1970-01-01
    • 2013-12-22
    • 1970-01-01
    • 2010-09-24
    • 1970-01-01
    • 2010-12-28
    相关资源
    最近更新 更多