使用gnuplot根据列值绘制多个图形

编程入门 行业动态 更新时间:2024-10-23 21:29:38
本文介绍了使用gnuplot根据列值绘制多个图形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有以下数据,我无法使用GNUPLOT进行绘制:

I have the following data, which I wan't to plot using GNUPLOT:

#TIME #VALUE #SOURCE 1 100 A 1 88 B 2 115 A 2 100 B 3 130 A 3 210 B

我希望绘制两行,具体取决于#SOURCE列的值. A 一行, B 一行. GNUPLOT是否可行?如果是,怎么办?

I want to have two lines drawn, depending on the value of column #SOURCE. One line for A and one line for B. Is this possible with GNUPLOT and if yes how?

是否有可能根据#TIME列得出#VALUE列的总和?意思是,对于#TIME中所有相等的条目,将对#VALUE中的值求和.

Is it possible to also draw a summation of column #VALUE depending over column #TIME? Means, that for all equal entries in #TIME, the values in #VALUE will be summed up.

预先感谢, 弗兰克

推荐答案

一种方法是使用grep定位以A或B结尾的行并绘制结果.如果您知道字符行将以以下结尾,则可以在带有for循环的单个绘图行中完成此操作:

One way to do it would be to use grep to locate lines ending with A or B and plot the result. You can do this in a single plot line with a for loop if you know the characters lines will end in:

plot for [s in 'A B'] sprintf("<(grep -v '%s$' data.dat)", s) u 1:2 w l

这会将您提供的数据(保存在data.dat中)绘制为两条不同的线.

This plots the data you provided (saved in data.dat) as two different lines.

您也可以将for部分更改为[s in 'word1 word2 word3']或您喜欢的任何其他字符串.如果您不知道字符/单词行将以结尾,则可能需要先两次传递文件以确定for循环的字符串,然后第二次进行绘制.

You could also change the for part to [s in 'word1 word2 word3'] or any other string you like. If you don't know the character/word lines will be ending with you would probably need to pass the file twice first to determine the string for the for loop and a second time to do the plotting.

更多推荐

使用gnuplot根据列值绘制多个图形

本文发布于:2023-05-29 23:06:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/355048.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   图形   gnuplot

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!