带框着色的gnuplot直方图
我的目标是用gnuplot 5.4框创建一个直方图,并用特定的RGB值对每个框进行着色(出于测试目的,它是“绿色”的,但在最终数据集中是#RRGGBB) 我的数据如下所示:带框着色的gnuplot直方图,gnuplot,histogram,Gnuplot,Histogram,我的目标是用gnuplot 5.4框创建一个直方图,并用特定的RGB值对每个框进行着色(出于测试目的,它是“绿色”的,但在最终数据集中是#RRGGBB) 我的数据如下所示: 5.800507 1 1 green 121.810653 6 1 green 133.411668 41 1 green 第1列-X值, 第二列-Y值, 第三列-框宽, 第四栏-rgb 这将工作并产生预期的图形输出: plot "data.out" using 1:2:
5.800507 1 1 green
121.810653 6 1 green
133.411668 41 1 green
第1列-X值,
第二列-Y值,
第三列-框宽,
第四栏-rgb
这将工作并产生预期的图形输出:
plot "data.out" using 1:2:3 with boxes
如果我将绘图更改为此,它将失败,错误为“x范围无效”,并发出警告“跳过没有有效点的数据文件”:
我在博客中找到了许多使用gnuplot 4.2实现这一点的例子,但它们都失败了,因为5.4中出现了相同的“x范围无效”错误。gnuplot不能(还?)使用颜色名称作为变量颜色的输入。
如果要为lc var…
使用颜色名称(作为字符串),请检查以下解决方法:
对于您的测试用例:只需将green
更改为0x00ff00
代码:
### variable color
reset session
$Data <<EOD
5.800507 1 1 0x00ff00
121.810653 6 1 0x00ff00
133.411668 41 1 0x00ff00
EOD
set style fill solid 1.0
plot $Data using 1:2:3:4 with boxes lc rgb variable
### end of code
###可变颜色
重置会话
$Data gnuplot开发版本(5.5)提供了一个函数rgbcolor(“colorname”)
,但该函数尚未出现在5.4中。因此,在5.5中,您可以使用1:2:3:(rgbcolor(stringcolumn(4)))和lc rgb变量来绘制$Data
### variable color
reset session
$Data <<EOD
5.800507 1 1 0x00ff00
121.810653 6 1 0x00ff00
133.411668 41 1 0x00ff00
EOD
set style fill solid 1.0
plot $Data using 1:2:3:4 with boxes lc rgb variable
### end of code