如何将字符串映射到RGB值?
数据文件如下:
# ID,Value, Region
A,30,North
B,26,North
C,49,South
D,55,East
...
在这里,我想将字符串(例如 region
)映射到RGB值,该值将用作 lc
color BoxXy
。它可以描述为伪代码:
if (region eq "North") {
"0x1b9e77"
} else if (region eq "South") {
"0xd95f02"
} else if (region eq "East") {
"0x7570b3"
} else {
"0xe7298a"
}
如何在gnuplot中获得此类映射?实际上,在这里,使用选项将 $ 3
映射到中的十六进制字符串。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在伪代码上定义基于映射功能:
之后,可以将其应用于列。
解决方案的关键时刻:
x eq” north“ ...
,因为我们比较字符串lc rgb变量
让我们控制 使用string> StringColumn(3)
而不是$ 3
,可以使用变量(无代码> RGB 您可以访问标准行颜色)的线颜色(无代码> rgb )You can define a mapping function basing on your pseudocode:
after that, you can apply it on your column.
The key moments of the solution:
x eq "North"...
because we compare stringslc rgb variable
let us to control the line color by a variable (withoutrgb
you can access to the standard line colors)stringcolumn(3)
instead of$3
is very important.