gnuplotv4.4:p期间插入的随机数据点

2024-09-30 20:23:40 发布

您现在位置:Python中文网/ 问答频道 /正文

----EDIT-----添加了示例数据和一个完整的简化python代码,该代码会产生相同的错误。在

在大约三分之一的绘图中,我从相同的代码生成,但不同的数据,我得到了一个倾斜的数据点。据我所知,这个数据点只在10,x(我的第二行数据)处失败,在我今天看到的每一个错误情况下(大约10,3)都给出一个点(10,3),而且没有一个数据文件将(10,3)作为数据点。我会上传照片现在,但我是一个新用户(需要更多的帖子)。在


通过python传递但保留gnuplot语法的错误输出的代码:

import os
D1='data_from_below.csv'
PLOTFILE='ALA1_STDEVP.png'
f=os.popen('gnuplot' ,'w')
print >>f, "set datafile separator ','"
print >>f, "plot '%s' u 1:2" % (D1)
print >>f, "ymax=GPVAL_DATA_Y_MAX"
print >>f, "ymin=GPVAL_DATA_Y_MIN"
print >>f, "ylen=ymax-ymin"
print >>f, "xmax=GPVAL_DATA_X_MAX"
print >>f, "xmin=GPVAL_DATA_X_MIN"
print >>f, "xlen=xmax-xmin"                               
print >>f, "set xrange [xmin:xmax]"
print >>f, "set yrange [ymin-0.5*ylen:ymax+0.5*ylen]"
print >>f, "set nokey"
print >>f, "set title 'STDEVP for ALA 1 of 3KYX'"
print >>f, "set xlabel 'Rotation angle'; set ylabel 'Electron Density'"
print >>f, "f(x) = mean_y; fit f(x) '%s' u 1:2 via mean_y" % (D1)
print >>f, "stddev_y = sqrt(FIT_WSSR / (FIT_NDF + 1 ))"
print >>f, "set label 1 gprintf('Mean = %g', mean_y) at 3, ymin-0.2"
print >>f, "set label 2 gprintf('Standard deviation = %g', stddev_y) at 2, ymax+0.2"
print >>f, "plot mean_y-(stddev_y) with filledcurves y1=mean_y lt 1 lc rgb '#bbbbdd' title 'booo', mean_y+(stddev_y) with filledcurves y1=mean_y lt 1 lc rgb '#bbbbdd', mean_y w l lt 3, '%s' u 1:2 w p pt 7 lt 1 ps 1" % (D1)
print >>f, "set terminal png large size 750,500; set out '%s'" % (PLOTFILE)
print >>f, "replot"
f.flush()

不会产生错误的简化代码:

^{pr2}$

示例数据,.csv格式:

3KYX_ALA_A_1,3KYX_ALA_A_16
0,1.770
10,1.933
20,2.042
30,2.184
40,2.441
50,2.629
60,2.756
70,2.849
80,2.699
90,2.549
100,2.206
110,1.827
120,1.571
130,1.438
140,1.326
150,1.346
160,1.491
170,1.648
180,1.690
190,1.754
200,1.674
210,1.487
220,1.318
230,1.189
240,1.020
250,0.960
260,1.008
270,1.151
280,1.373
290,1.620
300,1.733
310,1.851
320,1.933
330,1.981
340,1.870
350,1.775


Tags: 数据代码ltdata错误meand1print