如何从点文件内部向gnuplot中的每个点添加颜色 [英] How to add colors to every point in gnuplot from inside the point file

查看:87
本文介绍了如何从点文件内部向gnuplot中的每个点添加颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

阅读答案可以更改每个点的颜色,但是:

Reading this and this answer I understood that changing the colours of every point is possible, but:

  • 必须使用set palette model RGB defined ()进行定义,因此 如果我想要100种不同的颜色,我将必须定义所有这些颜色

  • it has to be defined using set palette model RGB defined (), hence if I want 100 different colours I will have to define all of them

在绘制点之前指定点的颜色.

the colour of the point is specified just before it is drawn.

我的问题是,有没有一种方法可以避免上述所有问题,例如按如下方式修改我的数据文件:

My question is, is there a way to avoid all of the above, for example modify my data file as follows:

x y z R   G   B
1 2 3 0   255 255 
5 6 2 255 0   0

用指定的颜色绘制相应的点吗?

And have the according point drawn with the specified colour?

推荐答案

在gnuplot 4.6+上尝试以下操作:

Try the following on gnuplot 4.6+:

rgb(r,g,b) = 65536 * int(r) + 256 * int(g) + int(b)
plot "data.dat" using 1:2:(rgb($3,$4,$5)) with points lc rgb variable

从手册中:

1.17.1.3 rgbcolor变量

变量告诉程序读取每个的RGB颜色信息 数据文件中的一行.这需要相应的附加 使用说明符中的列.多余的列被解释为 24位压缩RGB三重.如果直接在 数据文件,最简单的做法是将其指定为十六进制值(请参见 'rgbcolor').或者,使用说明符可以包含一个 如示例中所示,该表达式的计算结果为24位RGB颜色 以下.使用 tc rgbcolor变量类似地设置文本颜色.

variable tells the program to read RGB color information for each line in the data file. This requires a corresponding additional column in the using specifier. The extra column is interpreted as a 24-bit packed RGB triple. If the value is provided directly in the data file it is easiest to give it as a hexidecimal value (see 'rgbcolor'). Alternatively, the using specifier can contain an expression that evaluates to a 24-bit RGB color as in the example below. Text colors are similarly set using tc rgbcolor variable.

这篇关于如何从点文件内部向gnuplot中的每个点添加颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆