如何使用列值的颜色函数绘制直方图?
我想绘制直方图,但盒子的颜色应该是列内值的功能。如果我的文件的第12列中的值为据省至160,则颜色变化为红色。
我的脚本:
set xlabel 'elapsed' font ",14"
set ylabel 'NCPUS' font ",14"
set xtics font "Verdana,12"
set style fill solid border -1
set xtic rotate by -45 scale 0
color(x)=(x==160?1:2)
#p "< sort 'histo' -k10n" using 12:xticlabels(($10)/3600) with histogram notitle ls color(12)
p "< sort 'histo' -k10n" using 12:xticlabels(($10)/3600) with boxes notitle ls color(12)
我得到的:
我的数据:
User JobID JobName Partition State Timelimit Start End Elapsed ElapsedRaw NNodes NCPUS NodeList
--------- ------------ ---------- ---------- ---------- ---------- ------------------- ------------------- ---------- ---------- -------- ---------- ---------------
bouchet 6389 E423 epic COMPLETED 365-00:00+ 2022-02-28T20:32:49 2022-03-04T11:24:48 3-14:51:59 312719 5 160 lio[1-5]
6389.batch batch COMPLETED 2022-02-28T20:32:49 2022-03-04T11:24:48 3-14:51:59 312719 1 32 lio1
bouchet 6393 Fenc epic COMPLETED UNLIMITED 2022-03-04T12:08:07 2022-03-05T17:11:00 1-05:02:53 104573 5 160 lio[1-5]
6393.batch batch COMPLETED 2022-03-04T12:08:07 2022-03-05T17:11:00 1-05:02:53 104573 1 32 lio1
bouchet 6399 Fenc epic COMPLETED UNLIMITED 2022-03-05T17:11:12 2022-03-08T10:07:10 2-16:55:58 233758 5 160 lio[1-5]
6399.batch batch COMPLETED 2022-03-05T17:11:12 2022-03-08T10:07:10 2-16:55:58 233758 1 32 lio1
当我使用LC RGB变量时,我会得到:
boucher.plot", line 12: Not enough columns for variable color
请有什么想法吗?
I Would like to plot a histogram but the color of my boxes should be function of a value inside a column. If the value in column 12 of my file is egal to 160 the color change in red.
my script :
set xlabel 'elapsed' font ",14"
set ylabel 'NCPUS' font ",14"
set xtics font "Verdana,12"
set style fill solid border -1
set xtic rotate by -45 scale 0
color(x)=(x==160?1:2)
#p "< sort 'histo' -k10n" using 12:xticlabels(($10)/3600) with histogram notitle ls color(12)
p "< sort 'histo' -k10n" using 12:xticlabels(($10)/3600) with boxes notitle ls color(12)
What I get :
my data :
User JobID JobName Partition State Timelimit Start End Elapsed ElapsedRaw NNodes NCPUS NodeList
--------- ------------ ---------- ---------- ---------- ---------- ------------------- ------------------- ---------- ---------- -------- ---------- ---------------
bouchet 6389 E423 epic COMPLETED 365-00:00+ 2022-02-28T20:32:49 2022-03-04T11:24:48 3-14:51:59 312719 5 160 lio[1-5]
6389.batch batch COMPLETED 2022-02-28T20:32:49 2022-03-04T11:24:48 3-14:51:59 312719 1 32 lio1
bouchet 6393 Fenc epic COMPLETED UNLIMITED 2022-03-04T12:08:07 2022-03-05T17:11:00 1-05:02:53 104573 5 160 lio[1-5]
6393.batch batch COMPLETED 2022-03-04T12:08:07 2022-03-05T17:11:00 1-05:02:53 104573 1 32 lio1
bouchet 6399 Fenc epic COMPLETED UNLIMITED 2022-03-05T17:11:12 2022-03-08T10:07:10 2-16:55:58 233758 5 160 lio[1-5]
6399.batch batch COMPLETED 2022-03-05T17:11:12 2022-03-08T10:07:10 2-16:55:58 233758 1 32 lio1
and when I use lc rgb variable I get :
boucher.plot", line 12: Not enough columns for variable color
Any ideas please ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我希望这是一个常见的问题,但是,与编写几行代码相比,搜索合适的示例似乎需要更多的时间。
成分是
LC RGB变量
(检查help variable
)和三元操作员(检查help help ternary
)。脚本:
结果:
I expected this to be a frequently asked question, however, it seems it would take more time to search for a suitable example than writing a few lines of code.
The ingredients are
lc rgb variable
(checkhelp variable
) and ternary operator (checkhelp ternary
).Script:
Result: