macos - Gnuplot:向输出表添加一些用户数据列?

标签 macos unix gnuplot gnu

我只想借助“set table”命令将一些 gnuplot 生成的数据保存到数据文件中。 数据应该是一个向量及其长度。矢量偏移量是计算到输入文件“filed.dat”的任意点的。 将矢量数据打印到文件中没有问题。我这样做:

splot 'field.dat' using 1:2:3:(-$2):($3):($1):(sqrt(($1)**2+($2)**2+($3)**2)) with vectors;

输出例如是这样的:

# x y z delta_x delta_y delta_z type
-2 -3 -4  3 -4 -2 i
-1 -3 -4  3 -4 -1 i
 0 -3 -4  3 -4  0 i
 1 -3 -4  3 -4  1 i
 2 -3 -4  3 -4  2 i

但我想将计算出的向量长度添加到输出文件中。它应该看起来像这样:

 # x y z delta_x delta_y delta_z length type
    -2 -3 -4  3 -4 -2 5.39 i
    -1 -3 -4  3 -4 -1 5.10 i
     0 -3 -4  3 -4  0 5.00 i
     1 -3 -4  3 -4  1 5.10 i
     2 -3 -4  3 -4  2 5.39 i

有谁知道如何使用 gnuplot 来实现吗?

最佳答案

这在 gnuplot 中是不可能的,因为最多将六列写入输出文件(对于除向量以外的其他绘图样式,其数量更少)。

但是,您可以通过管道传输表输出,例如awk 添加此信息:

set output '| awk ''{\
  if (!match($1, "^#") && length()) {\
      print $1, $2, $3, $4, $5, $6, sqrt($4**2 + $5**2 + $6**2), $7\
  } else {\
      print $0}\
  }'' > field-out.dat'
set table
splot 'field.dat' using 1:2:3:(-$2):3:1 with vectors
unset table

您必须使用设置输出才能使用管道,设置表“| ...”不起作用。

关于macos - Gnuplot:向输出表添加一些用户数据列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19465644/

相关文章:

linux - 这个shell脚本有什么作用?

unix - unix下如何根据时间戳对文件进行排序?

ruby - 使用 ruby​​_gnuplot 在 Ruby 中制作动画 3d 散点图

pdf - pdfcairo 终端输出错误

ios - 了解 Swift 的数组实现

c - Printf 未在 Apple Clang 中打印到终端

linux - 如何使用 find 在 CSH 中复制带前缀的文件?

macos - 操作系统 X : Launching app from dock is a no-op if app is already running headless (via NSApplicationActivationPolicyProhibited)

objective-c - 获取除主应用程序之外的其他正在运行的应用程序的主菜单

unicode - 如何让 Gnuplot 使用 "unicode minus"符号表示负数