【问题标题】:Gnuplot: Variable colors (and linewidths) for 2D-Vector plotGnuplot:二维矢量图的可变颜色(和线宽)
【发布时间】:2011-08-20 07:50:34
【问题描述】:

我正在尝试在 gnuplot (version 4.4) 中创建具有 variable 颜色(和线宽)的 2D Vector-Plot。我已经查看了要点的示例:

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

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

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

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)。此外,我还尝试交换列,并使用随机值。但无论我做什么,箭头都是黑色的。

我有什么明显的遗漏吗?

提前致谢,

阿拉什

【问题讨论】:

    标签: variables vector colors gnuplot


    【解决方案1】:

    假设您想按矢量大小为数据文件着色,您还可以将palette 选项与cbrange 结合使用,例如(Gnuplot 4.6 示例)

    set cbrange [0:1]
    set palette rgbformulae 33,13,10
    plot "data" using 1:2:3:4:(sqrt($3**2+$4**2)) with vectors linecolor palette z
    

    【讨论】:

      【解决方案2】:

      我只会放一种颜色规格,例如

      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函数来完成

      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
      

      【讨论】:

      • 谢谢,成功了!回想起来,用 splot 代替 plot 似乎很愚蠢……
      • @Arash 很高兴听到它有帮助。
      • 知道为什么在尝试您的示例时出现错误“使用该样式的规格太多”吗?我正在使用 4.2(它是 4.4 的功能吗?)
      • @Bernhard - 我相信这是因为该示例适用于具有 4 个参数的向量,并且颜色是第 5 个参数(或“规格”)。
      猜你喜欢
      • 1970-01-01
      • 2015-07-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多