Gnuplot:如何将文件中的每一行绘制为单独的图形? [英] Gnuplot: How to plot each line from a file as a seperate figure?

查看:52
本文介绍了Gnuplot:如何将文件中的每一行绘制为单独的图形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道在gnuplot中绘制圆的命令:

I know the command to plot circle in gnuplot:

plot 'circle.txt' using 1:2:3 with circles

假设circle.txt包含n行,并且每行包含(centerXcenterYradius)个不同的圆,例如:

Suppose if circle.txt contains n lines and each line contains (centerX, centerY, radius) of different circles, e.g.:

#x  y   radius
0   0   1
1   1   2
2   2   3

如何生成包含n个不同圆圈的n个图像-每行一个图像?

How can I generate n images containing n different circles - one image per line?

推荐答案

这将与 gnuplot 4.4 及更高版本一起使用:

This will work with gnuplot 4.4 and higher:

gnuplot> n = "`awk 'END {print NR}' < circle.txt`"
gnuplot> i=0; while i<n{set term wxt i; plot 'circle.txt' every ::i::i using 1:2:3 with circles; i=i+1}

说明:

  • "`awk 'END {print NR}' < circle.txt`"确定文件中的行数
    (警告:在Windows 32位系统上不起作用)
  • i=0设置while循环的计数器
  • while i<n遍历文件的行
  • { }子句必须放在大括号中
  • set term wxt i此部分为每个图打开新窗口
  • ;
  • 分隔命令
  • plot 'circle.txt' every ::i::i using 1:2:3 with circles这仅绘制文件的第i行. 有关的更多信息绘制特定线条可以在这里找到.
  • i=i+1递增计数器
  • "`awk 'END {print NR}' < circle.txt`" to determine the number of rows in the file
    (Warning: This does not work on a Windows 32-bit system)
  • i=0 to set the counter for the while loop
  • while i<n loop through the rows of the file
  • { } while-clause has to be in curly braces
  • set term wxt i this portion opens the new window for each plot
  • separate commands by ;
  • plot 'circle.txt' every ::i::i using 1:2:3 with circles this plots just the ith line of the file. More information on plotting specific lines can be found here.
  • i=i+1 increment the counter

这篇关于Gnuplot:如何将文件中的每一行绘制为单独的图形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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