本文介绍了Gnuplot:2D-Vector图的可变颜色(和线宽)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在gnuplot(版本4.4)中创建具有可变颜色(和线宽)的2D矢量绘图。我看了点示例:

I am trying to create a 2D Vector-Plot with variable colors (and line-widths) in gnuplot (version 4.4) . I have looked at the examples for points:

splot "vectors.dat" u 1:2:3:4:(rgb($5,$6,$7)) w points pt 7 pointsize var linecolor rgb variable

其中 rgb 是将颜色转换为gnuplot友好格式的功能。

where rgb is a function which translates the color to a gnuplot friendly format.

对向量的修改似乎很简单,但是我偶然发现了几个问题。我的示例代码是(用于可变着色):

A modification toward vectors seemed straightforward, but I stumbled over several problems. My example code is (for variable coloring):

splot "vectors.dat" u 1:2:(rgb($5,$6,$7)):3:4:(rgb($5,$6,$7)) with vectors head filled size screen 0.05,15,45 linetype 1 linewidth 2 linecolor rgb variable

我也试图在第三栏中输入0,因为向量的gnuplots表示法是(x,y,z)(dx,dy,dz) 。此外,我还尝试过交换列,并使用随机值。但是,无论我做什么,箭头仍然是黑色的。

I have also tried to put 0 in the third column, since gnuplots notation of a vector is (x,y,z) (dx,dy,dz). Furthermore I have also tried to swap the columns, and used random values. But whatever I do, the arrows remain black.

我明显缺少什么吗?

感谢

Arash

推荐答案

我只会输入一种颜色规范,例如

I would put only one color specification, e.g.

set xrange [0:10]
set yrange [0:10]
plot "test.dat" using 1:2:3:4:5 with vectors lw 3 lc rgb variable

其中 test.dat 包含

1 1 2 0 0x000000
1 2 2 0 0xff0000
1 3 2 0 0xffff00
1 4 2 0 0x382288

相同可以使用以下内联 rgb 函数

The same can be done using the following inline rgb function

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

其中 test2.dat 现在读取

1 1 2 0 0 0 0
1 2 2 0 255 0 0
1 3 2 0 255 255 0
1 4 2 0 56 34 136

这篇关于Gnuplot:2D-Vector图的可变颜色(和线宽)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 01:20