GnuPlot中的线图,其中线宽是数据文件中的第三列? [英] Line plot in GnuPlot where line width is a third column in my data file?

查看:96
本文介绍了GnuPlot中的线图,其中线宽是数据文件中的第三列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含三列的数据文件:

I have a datafile that has three columns :

1 1.0 1
2 1.5 2
3 0.0 3
4 1.2 2.5
5 1.0 1
6 1.1 5

其中第一列是我的X值,第二列是我的Y值,第三列是线宽.我希望根据第三列线宽来绘制每个线段.

where the first column is my X value, the second column is my Y value, and the third column is the line width. I'd like for each line segment to be plotted according to the third column line width.

我尝试过:

plot 'file1.dat' using 1:2:3  with lines lw var

但是我得到了未定义的变量:var错误.

But I get undefined variable: var error.

在gnuplot中有可能吗?

Is this possible in gnuplot?

谢谢.

推荐答案

如果将第3列定义为点n和n + 1之间的线宽(因此该行的第3列的值将被忽略),您可以作弊:

If you define column 3 as the linewidth between points n and n+1 (so the value of col. 3 of the row will be ignored) you can cheat:

stat 'file1.dat'
n=STATS_records
plot for [i=0:0] 'file1.dat' using 1:2:(alma=$3) every ::i::i w l lc 1 lw 1
plot for [i=0:n-1] 'file1.dat' using 1:2:(alma=$3) every ::i::i+1 w l lc 1 lw alma notitle

OR

plot 'file1.dat' u 0:1
n=GPVAL_DATA_X_MAX
plot for [i=0:0] 'file1.dat' using 1:2:(alma=$3) every ::i::i w l lc 1 lw 1
plot for [i=0:n] 'file1.dat' using 1:2:(alma=$3) every ::i::i+1 w l lc 1 lw alma notitle

您需要第一个plot for[i=0:0]来初始化"变量"alma".

You need the first plot for[i=0:0] to 'initialize' variable 'alma'.

这篇关于GnuPlot中的线图,其中线宽是数据文件中的第三列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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