놀랍게도 이것은 gnuplot에 내장되어 있지 않습니다. gnuplot이 데이터를 스트림으로 처리하는 방법 때문에 gnuplot의 개별 데이터 포인트 나 데이터 포인트의 범위를 조작하는 좋은 방법은 없습니다.
gnuplot의 가장 큰 장점 중 하나는 외부 스크립트와 도구를 호출하는 것이 얼마나 쉬운 지입니다. 당신의 gnuplot 내에서 데이터를 처리하는 외부 스크립트를 사용하려면, 당신은 이런 식으로 작업을 수행 할 수 있습니다
plot "<script.py data.dat" u 1:2
는 예를 들어, 아래의 파이썬 스크립트를 사용할 수 있습니다. 그것은 일종의 잔인한 일이지만, 스크립트 나 명령 줄에서 하드 코딩 된 매개 변수 값을 설정할 수 있습니다.
#!/usr/bin/python2.7
import sys
if (len(sys.argv) > 6):
print ""
print "This script takes one mandatory argument, the name of a file containing"
print "data to be plotted. It takes up to four optional arguments as follows:"
print " 1) the number of points before a data point to add into average."
print " 2) the number of points after a data point to add into average."
print " 3) the column number of y data (first column is column 1)"
print " 4) the column number of x data (first column is column 1)"
print ""
exit()
# set variable defaults
box_back = 10 # number of points before current point to add into average
box_front = 10 # number of points after current point to add into average
y_col = 2 # column number of y data (first column is column 1)
x_col = 1 # column number of x data (first column is column 1)
# assign variables from command line arguments
inputFileName = str(sys.argv[1])
if (len(sys.argv) > 2):
box_back = int(sys.argv[2])
if (len(sys.argv) > 3):
box_front = int(sys.argv[3])
if (len(sys.argv) > 4):
y_col = int(sys.argv[4])
if (len(sys.argv) > 5):
x_col = int(sys.argv[5])
# open input file
f = open(inputFileName)
# make list from lines in file
lines = f.readlines()
# make sure boxcar average will work
if ((box_back + box_front + 1) > len(lines)):
print ""
print "ERROR: too many points for boxcar averaging."
print ""
exit()
# this is the number of points encompassed in the boxcar average
num_points = box_back + box_front + 1
# this variable is the running sum.
sum_vals = 0
# add up values for first boxcar average
for i_ in range(0,num_points):
sum_vals += float(lines[i_].split()[y_col-1])
print float(lines[box_back].split()[x_col-1]),sum_vals/num_points
# each subsequent average differs only in the first and last points from the
# previous average.
for i_ in range(box_back+1,len(lines)-box_front):
sum_vals += float(lines[i_+box_front].split()[y_col-1])
sum_vals -= float(lines[i_-box_back-1].split()[y_col-1])
print float(lines[i_].split()[x_col-1]),sum_vals/num_points
베 지어 커브가 내장되어 있으며 '플롯'file.dat "u 1 : 2 s b'로 사용할 수 있습니다. 일종의 평균을 갖는 것이 좋지만 관습적인 것이 더 좋을 것이므로 질문은 여전히 열려 있습니다. –