- 积分
- 259
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2017-5-8
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 呼小喵喵 于 2017-5-25 13:53 编辑
参照王老师之前发的脚本,对读取数据那块进行了修改,结果还是错误。求指导脚本如下:
#Create normal distribution point data
fn = 'f:/lightning-0514/0514IC.txt'
tf = open(fn)
x1 = []
y1 = []
for aline in tf:
if aline.isspace():
continue
datalist = aline.split()
x = float(datalist[1])
y = float(datalist[0])
x1.append(x)
y1.append(y)
x = array(x1)
y = array(y1)
#Calculate point density
x_g = linspace(x.min(), x.max(), 100)
y_g = linspace(y.min(), y.max(), 100)
z2,x2,y2,z = griddata((x,y), None, xi=(x_g, y_g), method='inside_count')
#Sort the points by density, so that the densest points are plotted last
idx = argsort(z)
x = x[idx]
y = y[idx]
z = z[idx]
#Plot scatter point colored by density
ls = scatter(x, y, s=4, c=z, edgecolor=None, cnum=20)
colorbar(ls)
title('Scatter density plot example') |
提示错误如下:
File "<iostream>", line 10
x = float(datalist[1])
^
SyntaxError: mismatched input '' expecting DEDENT
数据就两列:
0514IC.txt
(189.58 KB, 下载次数: 20)
|
|