You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

xmgrace中-nxy与-pipe选项能否联用实现无临时文件多列绘图?

Plotting Multiple Datasets with xmgrace via Pipe (No Temp File)

Absolutely, you can do this! The issue with your original somecommand | xmgrace -pipe is that by default, xmgrace's pipe mode only reads the first two columns (x and y1) as a single dataset, ignoring the rest. To get all four y columns plotted against x, you just need to explicitly tell xmgrace to parse the input as multiple columns using the -nxy flag in a read block command.

Here's the command that will work:

somecommand | xmgrace -pipe << EOF
read block -nxy
$(cat -)
EOF

How this works:

  • The << EOF starts a here-document that sends commands directly to xmgrace's pipe interface.
  • read block -nxy tells xmgrace to interpret the incoming data exactly like it would with the command-line -nxy option: the first column is x, and each subsequent column becomes a separate y dataset.
  • $(cat -) reads the output from somecommand (piped in) and feeds it straight into the read block command.

This will generate four distinct curves (y1 vs x, y2 vs x, etc.) just like your original temp file method, but without the intermediate tmp.dat file.

If you prefer a more concise one-liner, process substitution works too:

xmgrace -pipe < <(echo "read block -nxy"; somecommand)

This combines the control command and your data into a single input stream for xmgrace, achieving the same result.

内容的提问来源于stack exchange,提问作者Saurish Chakrabarty

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 09:35:14