string - 来自字符串的 gnuplot 图

标签 string plot gnuplot

是否可以将数据传递到字符串中?

我的意思是做这样的事情:

plot "09-13-2010,2263.80 09-14-2010,2500" using 1:2 with lines

最佳答案

可以执行以下操作:

set xdata time
set timefmt "%m-%d-%y"     
plot "< echo '09-13-2010,2263.80 09-14-2010,2500' | tr ' ' '\n' | tr ',' ' '" using 1:2 with lines

<字符向 Gnuplot 表明我们希望我们的输入来自命令的输出。 Gnuplot 用换行符分隔记录。记录组由空白记录分隔。在一条记录中,默认的列分隔符是一个空格。在上面的例子中 tr用于将您的数据拆分为行,并将行重写为记录。

从字符串绘制数据的另一种方法是使用“-”输入说明符,然后从命令行加载数据。一个程序可以很容易地发出以下内容:
set xdata time
set timefmt "%m-%d-%y"
plot '-' using 1:2 with lines
09-13-2010 2263.80
09-14-2010 2500
e

最好的办法是使用输入文件,如:
09-13-2010 2263.80
09-14-2010 2500

假设输入文件名为 mydata.txt ,然后您可以使用以下命令绘制它:
set xdata time
set timefmt "%m-%d-%y"
plot 'mydata.txt' using 1:2 with lines

上面的所有示例都为您提供了类似的信息:
alt text

如果您想使用日期和“-”输入绘制两个数据系列,您可以执行以下操作:
set xdata time
set timefmt "%m-%d-%y"
plot '-' using 1:2  title "Series 1" with lines,'-' using 1:2 title "Series 2" with lines
09-13-2010 2263.80
09-14-2010 2500
e
09-13-2010 2500
09-14-2010 2263.80
e

前面的例子给出:
alt text

关于string - 来自字符串的 gnuplot 图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3709462/

相关文章:

c# - 我如何 "ASCII armor"我的 MemoryStream?

gnuplot - gnuplot 中同一数据文件中的多个数据集

string - Flutter/Dart 中单引号和双引号的区别

php - 从仅包含单词的字符串创建首字母缩略词

随单元格值变化的字符串?

matlab - 如何在 MATLAB 中绘制特定多边形区域之外的点

r - 将 3D abline 添加到 Rlattice 包中的云图

python - 使用 Python seaborn 绘制两侧分组条形图

Gnuplot:关键元素的位置

绘制同一文件中两列的差异