带框阴影的 gnuplot 直方图
gnuplot histogram with box shading
我的目标是使用 gnuplot 5.4 框创建一个直方图,并用特定的 RGB 值对每个框进行阴影处理(出于测试目的,它是“绿色”但在最终数据集中将是#RRGGBB)
我的数据是这样的:
5.800507 1 1 green
121.810653 6 1 green
133.411668 41 1 green
第 1 列 - X 值,
第二列 - Y 值,
第 3 列 - 框宽,
第 4 列 - rgb
这有效并产生预期的图形输出:
plot "data.out" using 1:2:3 with boxes
如果我将绘图命令更改为此,它会失败并显示错误“x range is invalid”并且还会给出警告“Skipping data file with no valid points”:
plot "data.out" using 1:2:3:4 with boxes lc rgb variable
我在博客中找到了一些使用 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
结果:
我的目标是使用 gnuplot 5.4 框创建一个直方图,并用特定的 RGB 值对每个框进行阴影处理(出于测试目的,它是“绿色”但在最终数据集中将是#RRGGBB)
我的数据是这样的:
5.800507 1 1 green
121.810653 6 1 green
133.411668 41 1 green
第 1 列 - X 值, 第二列 - Y 值, 第 3 列 - 框宽, 第 4 列 - rgb
这有效并产生预期的图形输出:
plot "data.out" using 1:2:3 with boxes
如果我将绘图命令更改为此,它会失败并显示错误“x range is invalid”并且还会给出警告“Skipping data file with no valid points”:
plot "data.out" using 1:2:3:4 with boxes lc rgb variable
我在博客中找到了一些使用 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
结果: