- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
好的,所以我将数据以以下形式传输到 GNUplot,例如:
2013-11-04 20:00:12,875,350,112,29,38,4,44,10,632,121
我在我的 Python 代码中设置了以下内容:
gnuplot.stdin.write("plot '-' u 1:2 t 'aa',\
'' u 1:3 t 'aa in',\
'' u 1:4 t 'bb',\
'' u 1:5 t 'bb in',\
'' u 1:6 t 'cc',\
'' u 1:7 t 'cc in',\
'' u 1:8 t 'dd',\
'' u 1:9 t 'dd in',\
'' u 1:10 t 'ee';\n")
<罢工> 但是我不断收到以下错误:
gnuplot> plot '-' u 1:2 t 'aa', '' u 1:3 t 'aa in', '' u 1:4 t 'bb', '' u 1:5 t 'bb in', '' u 1:6 t 'cc', '' u 1:7 t 'cc in', '' u 1:8 t 'dd', '' u 1:9 t 'dd in', '' u 1:10 t 'ee';
^
line 1271: warning: Skipping data file with no valid points
有什么想法吗?
<罢工>###UPDATE:###
<罢工>基于@Christoph 的反馈;这是我目前使用的代码:
cur.execute(sql)
data = cur.fetchall()
c = 0
for k in data:
dataElement = data[c]
gnuplot.stdin.write("plot '-' u 1:2 t 'aa',\
'' u 1:3 t 'aa in',\
'' u 1:4 t 'bb',\
'' u 1:5 t 'bb in',\
'' u 1:6 t 'cc',\
'' u 1:7 t 'cc in',\
'' u 1:8 t 'dd',\
'' u 1:9 t 'dd in',\
'' u 1:10 t 'ee';\n")
gnuplot.stdin.write("%s,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i\n" % dataElement[:])
gnuplot.stdin.write("e\n")
c = c + 1
<罢工>
最佳答案
您必须为每个'-'
编写自己的数据 block 。 ''
只会让您免于重新输入文件名,但不会重复使用数据。考虑例如以下 gnuplot 脚本:
plot '-', '-'
2
4
6
e
10
12
14
e
还要确保您的分隔符设置正确:set datafile separator ','
。
这是一个最小的 python 脚本,它绘制了来自 stdin
的两个数据集,列之间用逗号分隔:
#!/usr/bin/env python
import subprocess
gnuplot = subprocess.Popen(["gnuplot"], stdin=subprocess.PIPE)
gp_wrt = gnuplot.stdin.write
gp_wrt("set terminal pngcairo\n")
gp_wrt("set output 'test.png'\n")
gp_wrt("set datafile separator ','\n")
gp_wrt("plot '-' with lines title 'mytitle',\
'-' with lines title 'other title'\n")
for i in range(11):
gp_wrt("{},{}\n".format(i, i**2))
gp_wrt("e\n")
for i in range(11):
gp_wrt("{},{}\n".format(i, (0.5*i)**2))
gp_wrt("e\n")
所以对于你的数据,它可能看起来像
gnuplot.stdin.write("plot '-' u 1:2 t 'aa',\
'' u 1:3 t 'aa in',\
'' u 1:4 t 'bb',\
'' u 1:5 t 'bb in',\
'' u 1:6 t 'cc',\
'' u 1:7 t 'cc in',\
'' u 1:8 t 'dd',\
'' u 1:9 t 'dd in',\
'' u 1:10 t 'ee';\n")
for i in range(10):
for dataElement in data:
gnuplot.stdin.write("%s,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i\n" % dataElement[:])
gnuplot.stdin.write("e\n")
但在那种情况下你可以简单地使用:
gnuplot.stdin.write("plot '-' u 1:2 t 'aa',\
'' u 1:2 t 'aa in',\
'' u 1:2 t 'bb',\
'' u 1:2 t 'bb in',\
'' u 1:2 t 'cc',\
'' u 1:2 t 'cc in',\
'' u 1:2 t 'dd',\
'' u 1:2 t 'dd in',\
'' u 1:2 t 'ee';\n")
for i in range(10):
for dataElement in data:
gnuplot.stdin.write("%s,%i\n" % (dataElement[0], dataElement[i])
gnuplot.stdin.write("e\n")
即每次你只写相关的专栏。
关于python - GNUplot stdin,如何绘制多条线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20136763/
我有以下类型的文件: ... 我想从 (x,y) 值绘制一个散点图,在不同数据集中的第一列中有不同的字符串,这些字符串将用不同的颜色绘制(我有许多不同的 x,y 值但只有几个不同的字符串)
有谁知道我如何在 GNU Plot 的条形图顶部放置一组值的折线图?我的条形图工作得很好,但我不知道如何在不同的列上添加折线图。 我100%迷路了!我可以很容易地用 excel 做到这一点,但它看起来
我在 x_i 点有数据点 f(x_i)(函数 f 未知,只有数值),f(0) = 0。数据显示小 x 处的峰状结构,随后是较大 x 处的缓慢肩部衰减设置在最大值的一半。我想通过这些数据点绘制平滑线。
更新:此问题已在较新版本 (>5.0) 的 gnuplot 中解决;请参阅@andyras 的回答。 我很难让 gnuplot 在非 postscript 终端中创建带有粗体和增强文本的标签。下面的脚
你好有没有办法完全重置gnuplot,即在中使用gnuplot同 状态为刚刚启动后? Reset 不会终止变量或函数, undefine 不能用作“undefine *”,因为第一个字符必须是字母。
我想用彩色背景和图案填充条形图。在Gnuplot中有可能吗? 我正在使用Gnuplot 4.6.5 我现在拥有的代码: # set terminal pngcairo transparent enh
我想用 gnuplot 做一个条形图。 我使用了这个设置 set style data boxes set style fill solid plot 'foo.dat' using 1:2:(1)
在 gnuplot 中,给定 f 和 g 两个从平面到实线的函数,我将在 g 获得正值时绘制 f。我有这个代码: set xrange [-2:2] set yrange [-2:2] set iso
只是想习惯 gnuplot。我在这个网站上搜索了几页寻找答案,阅读了文档(4.6),但仍然没有找到答案。说我有一个这样的数据文件: 0.0 0 1.0 25 2.0 55 3.0 110 4.0 45
我刚开始使用 gnuplot,我已经关注了 this question它根据我的需要绘制数据。但是,我非常想也包括错误栏。我尝试通过添加最小和最大错误列来做到这一点,如下所示: Broswer,Vid
我有一个包含30列和N行的数据文件。每行对应于x = {1,...,30}的函数f(x)的30个值。数据文件具有以下模式: # f(1) f(2) ... f(30) 1 7.221 5.302 ..
我正在绘制一些具有不同X范围的数据,我想根据当前X范围内数据的最大值和最小值更改yrange。当我使用GPVAL_Y_MAX和GPVAL_Y_MIN时,这些值对应于整个数据的最大值和最小值,而不仅仅是
我尝试搜索,但是找不到针对此特定条件的解决方案。在我的情节中,我正在比较两条痕迹。我正在使用折线图,并且两条迹线都以不同的颜色绘制。 plot "delay_try1.dat" using 1:2 t
我有一个非常简单的数据集: Critical 2 High 18 Medium 5 Low 14 根据该数据集在 gnuplot 中创建条形图很容易,但所有条形图的颜色都相同。我希望将 Critica
我正在使用 gnuplot 创建两个相邻的图。我想给整个事情一个标题,但如果我使用标准的 set title "blah" 命令,我会得到两个标题 - 每个图一个。我怎样才能只获得一个标题(位于图上方
我正在尝试在 gnuplot 中绘制水平直方图。 这是我当前的垂直(通常类型)直方图: width=0.5 hist(x,width)=width*floor(x/width)+width/2.0 s
我想在 gnuplot 中绘制多个有界函数。 IE。绘制从 0 到 2 的 x 和从 1 到 3 的 x^2 并将它们一起显示。 如何绘制具有不同界限的函数? 我知道如何执行分段函数,例如 (x <
例如,给定以下数据文件(本例中为 x^2): 0 1 4 9 16 25 gnuplot 可以绘制点以及点之间的差异,就像这样: 0 0 1 1 # ( 1 - 0 = 1) 4 3 # (
我正在尝试尝试一些简单的回归线作为 gnuplot 图的基础。然而,无论我做什么,我都无法在图表上得到多于一条的拟合线。这可能吗?这是我的(当前)gnuplot 程序...... set title
有什么方法可以迭代地从多个文件中检索数据并将它们绘制在 gnuplot 中的同一个图表上。假设我有像data1.txt,data2.txt......data1000.txt这样的文件;每个都有相同数
我是一名优秀的程序员,十分优秀!