gnuplot 中输入数据的标签

发布于 2024-08-13 13:04:28 字数 227 浏览 1 评论 0原文

我有一个看起来像这样的数据文件,

#index name1 name2 name3
1 2 3 4
2 3 4 5
3 4 5 6
4 5 6 7

我想绘制 3 条线:

plot "data" using 1:2 with lines,\
...

除了线标签之外,这工作正常。如何指定数据文件中的列名称?

I have a datafile that looks like this

#index name1 name2 name3
1 2 3 4
2 3 4 5
3 4 5 6
4 5 6 7

I want to plot 3 lines:

plot "data" using 1:2 with lines,\
...

This works ok, except for the line labels. How can I specify the column names in the datafile?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

つ低調成傷 2024-08-20 13:04:28

如果您有 gnuplot 4.2 或更高版本,则可以相当轻松地完成此操作。不过,您需要删除第一行中的注释标记。

对于这样的文件:

index name1 name2 name3
1 2 3 4
2 3 4 5
3 4 5 6
4 5 6 7

以下将执行您想要的操作:

set key autotitle columnheader
plot 'a.dat' u 1:2 w l, '' u 1:3 w l, '' u 1:4 w l

如果我在绘图之前设置术语哑,我会得到一个漂亮的ascii图。我喜欢 gnuplot!

7 ++----------+----------+-----------+-----------+----------+---------$$
  +           +          +           +           +         name1$****** +
  |                                                       $name2 ###### |
  |                                                 $$$ name3 $$$ |
6 ++                                          $$$                  ###
  |                                     $$$                  ######  |
  |                               $$$                  ######        |
  |                         $$$                  ######              |
5 ++                   $$$                  ######                  ***
  |              $$$                 ######                  ******  |
  |        $$$                 ######                  ******        |
  |  $$$                 ######                  ******              |
4 $$                  #####                  ******                   ++
  |              ######                 ******                          |
  |        ######                 ******                                |
  |  ######                 ******                                      |
3 ###                  *****                                           ++
  |              ******                                                 |
  |        ******                                                       |
  +  ******   +          +           +           +          +           +
2 ***---------+----------+-----------+-----------+----------+----------++
  1          1.5         2          2.5          3         3.5          4

If you have gnuplot 4.2 or newer, you can do this fairly easily. You will need to get rid of the comment marker in the first line though.

With a file like this:

index name1 name2 name3
1 2 3 4
2 3 4 5
3 4 5 6
4 5 6 7

the following will do what you want:

set key autotitle columnheader
plot 'a.dat' u 1:2 w l, '' u 1:3 w l, '' u 1:4 w l

If I do set term dumb before plotting, I get a nice ascii plot. I love gnuplot!

7 ++----------+----------+-----------+-----------+----------+---------$$
  +           +          +           +           +         name1$****** +
  |                                                       $name2 ###### |
  |                                                 $$$ name3 $$$ |
6 ++                                          $$$                  ###
  |                                     $$$                  ######  |
  |                               $$$                  ######        |
  |                         $$$                  ######              |
5 ++                   $$$                  ######                  ***
  |              $$$                 ######                  ******  |
  |        $$$                 ######                  ******        |
  |  $$$                 ######                  ******              |
4 $$                  #####                  ******                   ++
  |              ######                 ******                          |
  |        ######                 ******                                |
  |  ######                 ******                                      |
3 ###                  *****                                           ++
  |              ******                                                 |
  |        ******                                                       |
  +  ******   +          +           +           +          +           +
2 ***---------+----------+-----------+-----------+----------+----------++
  1          1.5         2          2.5          3         3.5          4
冬天旳寂寞 2024-08-20 13:04:28

columnheader(n)

set key autotitle columnheader 更详细/灵活:

plot 'my.dat' using 1:2 title columnheader(2), \
    '' using 1:3 title columnheader(3)

在 Gnuplot 4.6、Ubuntu 15.10 上测试。

columnheader(n)

More verbose / flexible than set key autotitle columnheader:

plot 'my.dat' using 1:2 title columnheader(2), \
    '' using 1:3 title columnheader(3)

Tested on Gnuplot 4.6, Ubuntu 15.10.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文