- 积分
- 63
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2016-9-5
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 kangsite 于 2019-1-1 22:38 编辑
请问哪位知道,如何绘制站点数据效果类似附件?求python或C++算法
数据格式如下:
Stid,Longitude,Latitude,Precipitation6h
1,113.059,29.4966,11.7053
2,113.061,29.497,8.96478
3,113.064,29.4974,8.9645
4,113.066,29.4978,8.96411
5,113.068,29.4982,8.96379
6,113.062,29.4898,8.94334
7,113.064,29.4902,8.94116
8,113.066,29.4905,8.94057
9,113.068,29.4909,8.94
10,113.07,29.4913,8.93962
11,113.077,29.4932,0.001
12,113.063,29.4829,8.90352
13,113.065,29.4833,8.90423
14,113.067,29.4837,8.90521
15,113.069,29.4841,8.90614
16,113.071,29.4845,8.90729
17,113.076,29.487,0.00100177
18,113.083,29.4947,11.5452
19,113.087,29.4993,11.5392
20,113.081,29.489,8.81343
21,113.064,29.4759,8.86586
22,113.066,29.4763,8.86758
23,113.068,29.4768,8.86918
24,113.07,29.4772,8.87062
25,113.072,29.4777,8.87233
我用的代码如下
def contour(x, y, z, linewidth=2, labels=None):
"""
Plots contours for non-evenly spaced data.
x,y,z must be 1d arrays.
lines = # of contour lines (default 18 )
linewidth = line width of lines (default 2 )
"""
assert x.shape[0] == y.shape[0] == z.shape[
0], "arrays x,y,z must be the same size"
# make a grid that surrounds x,y support
xi = np.linspace(x.min(), x.max(), 100)
yi = np.linspace(y.min(), y.max(), 100)
xx, yy = np.meshgrid(xi, yi)
# grid the data.
zi = griddata((x, y),
z, (xi[None, :], yi[:, None]),
method='linear',
fill_value=np.nan)
# contour the gridded data, plotting dots at the randomly spaced data points.
# plt.figure()
# CS = plt.contour(xi, yi, zi, linewidth=2)
CS = plt.contourf(xi, yi, zi)
if labels:
plt.xlabel(labels[0])
plt.ylabel(labels[1])
# plot data points.
# plt.scatter(x, y, c=z, s=60, alpha=0.7, edgecolors="none")
plt.xlim(x.min(), x.max())
plt.ylim(y.min(), y.max())
plt.show()
绘制效果很难看
|
|