2012-11-30 41 views
2

我有这样一个数据文件堆积条形图:显示单个条形图和同积

"Execution" 500 
"Overhead 1" 200 
"Overhead 2" 75 

我想绘制该数据的柱状图,显示执行时间为单条线图,但间接费用1间接费用2作为单个堆积条形图。

这是我到目前为止有:

set terminal postscript eps 24 
set output "wq_time_profile.eps" 
set size 0.95,0.95 
set boxwidth 1.0 relative  
set style fill solid 0.5 noborder 
set style data histogram 
set style histogram cluster gap 1 
set ylabel "Time (mins)"                  
plot "wq_time_profile.dat" u 1 notitle, "" u 2 notitle, "" u 3 notitle 

我不能完全得到我的周围如何显示行2和3堆积条形图同时显示作为独立的条形图第1行头同样的情节。这可能在gnuplot?我正在使用gnuplot v4.2。谢谢!

编辑:修改了标题和问题澄清,该地块需要包含在同一个独立的条形图和堆积条形图水道同积

+1

感谢您的回答。我今天学到了新的东西:) – mgilson

回答

2

这似乎工作:

set style fill solid 0.5 noborder 
set style histogram columnstacked 
set style data histogram 
set ylabel "Time (mins)" 
plot "test.dat" u 2 notitle with histogram 

如果你想有个带颜色的标签的关键:

set style histogram columnstacked 
set style data histogram 
set style fill solid 0.5 noborder 
set ylabel "Time (mins)" 
plot "test.dat" u 2:key(1) with histogram 

在阅读你的编辑和玩了一下后,这仍然是可能的,但我需要修改你的数据文件。 (我希望这是好的):

"Execution" 500 


"foo" NaN 
"Overhead 1" 200 
"Overhead 2" 75 

现在绘图脚本:

set style histogram columnstacked 
set style data histogram 
set style fill solid 0.5 noborder 
set ylabel "Time (mins)" 
plot for [i=0:1] "test.dat" index i u ($2):key(1) with histogram 

还有一堆微妙之处这里。这对空白记录是一种为绘图时使用的gnuplot创建单独的“索引”的方法。第一个栏本身就是一个数据集。问题在于,Gnuplot会将索引0中的第一条记录与索引1中的第一条记录进行匹配,并使用相同的颜色对它们进行绘制。这很丑陋。所以我们需要在index = 1数据集中插入一个假记录,它不会绘制任何图,但会占用一个颜色。这就是"foo" NaN产品线的设计目的。我还需要修改plot行来绘制两个索引。并且使用规范需要从2:key(1)更改为($2):key(1),因为两种形式处理缺失数据的方式略有不同。

+0

感谢mgilson的答案!但是,我意识到我的问题并不清楚。我现在编辑它来澄清它。我在这个问题中试图做的是在一个条形图中显示第1行,同时在堆积的条形图中显示第2行和第3行。 – dpandiar

+0

@dpandiar - 已更新。希望它能做到你现在想要的。 – mgilson

+0

完美!这就像一个魅力!我只需手动设置xtics .. – dpandiar