Gnuplot 为什么我的柱状图有一部分行为不端?
我想用方框绘制一个类似直方图的图表,其中的条形图有不同的颜色 以下是我的数据:Gnuplot 为什么我的柱状图有一部分行为不端?,gnuplot,histogram,Gnuplot,Histogram,我想用方框绘制一个类似直方图的图表,其中的条形图有不同的颜色 以下是我的数据: stage 11402.364 100% 1 App1 78.552 0.69% 2 App2 11323.812 99.30% 2 Read 8.469 0.07% 3 Write 41.285 0.04% 3 Repeat 5748
stage 11402.364 100% 1
App1 78.552 0.69% 2
App2 11323.812 99.30% 2
Read 8.469 0.07% 3
Write 41.285 0.04% 3
Repeat 5748.351 50.41% 3
Count 4933.746 43.27% 3
Count_1 3841.355 33.69% 4
Count_2 1092.391 9.59% 4
但是我发现lc-rgb变量
不适合我。目前,我正在使用gnuplot4.2。在4.2中,用于4.2版的第三个数字是boxwidth,而不是box color
但我尝试了以下方法。因为我只需要4种颜色,所以我尝试使用以下代码手动绘制不同的颜色条:
set boxwidth 0.5 relative
set style fill solid 0.5
set xtics rotate
plot 'histogramdata_2.txt' using ($4 == 1 ? $0 : 1/0):2:xtic(1) with boxes lc 1 , \
'' using ($4 == 2 ? $0 : 1/0):2:xtic(1) with boxes lc 2 , \
'' using ($4 == 3 ? $0 : 1/0):2:xtic(1) with boxes lc 3 , \
'' using ($4 == 4 ? $0 : 1/0):2:xtic(1) with boxes lc 4
这是我得到的,这几乎是我想要的:
但是为什么第四列为1的第一个条会这样呢?我已经调了一段时间,但感到困惑。我需要一些帮助
我认为最好在这里发布一个新问题,因为它与原来的问题有点不同 这是一个bug,已在4.6.4或4.6.5中修复。我对您的脚本和数据集进行了一些研究:当只绘制一个框时,就会出现此错误,并且与使用过滤的特定
无关。其他一些情况:
当我从数据文件中删除“App2”行时,即对于lc 1和lc 2,每一行只有一行,则前两个框根本不打印
当我只绘制一个带有
plot 'histogramdata_2.txt' using 0:2:xtic(1) every ::::0 with boxes
我第一个盒子也搞错了
使用awk
进行外部筛选时相同:
set boxwidth 0.5 relative
set style fill solid 0.5
set xtics rotate
awk(c, f) = sprintf("awk '{ if ($4 == %d) { print NR, $0 } }' %s", c, f)
file = 'histogramdata_2.txt'
set style data boxes
plot '< '.awk(1, file) using 1:3:xtic(2), \
'< '.awk(2, file) using 1:3:xtic(2), \
'< '.awk(3, file) using 1:3:xtic(2), \
'< '.awk(4, file) using 1:3:xtic(2)
相对设置框宽0.5
将样式填充实体设置为0.5
设置xtics旋转
awk(c,f)=sprintf(“awk'{if($4==%d){print NR,$0}}}'%s',c,f)
文件='historogramdata_2.txt'
设置样式数据框
使用1:3:xtic(2)绘制'<'.awk(1,文件)\
“<”.awk(2,文件)使用1:3:xtic(2)\
“<”.awk(3,文件)使用1:3:xtic(2)\
“<”.awk(4,文件)使用1:3:xtic(2)
不,我没有找到解决方法(我也尝试过包含一些伪值,并使用适当的set xrange
跳过它们,但没有成功)。那么从哪个版本开始,支持lc rgb变量
?目前,我使用的是4.2。我正计划更新这个工具…我不知道,但是如果你正在升级,你应该去最新的版本,即5.0