【发布时间】:2020-10-04 01:49:13
【问题描述】:
大家好, 我试图通过在包含 sst 的空间图上使用散点图来显示热带气旋的轨迹。现在,在绘制轨迹时,散点图似乎并未绘制所有图,主要是在陆地上看到它没有绘制点。我无法确定我的代码在哪里做错了,如果有人可以在这方面提供帮助,将不胜感激。我将我的部分代码连同 lat long 值和我生成的图一起发布。我将 lat long 数据作为文本提供如下:
Lat Lon grade
10.4 87 D
10.9 86.3 D
10.9 86.3 CS
11.1 86.1 CS
11.4 86 CS
11.5 86 SCS
12 86 VSCS
12.5 86.1 VSCS
13.2 86.3 ESCS
13.4 86.2 SuCS
14 86.3 SuCS
14.9 86.5 SuCS
15.6 86.7 SuCS
16.5 86.9 ESCS
17.4 87 ESCS
18.4 87.2 ESCS
19.1 87.5 ESCS
20.6 88 ESCS
21.9 88.4 VSCS
23.3 89 SCS
24.2 89.3 CS
25 89.6 DD
25.4 89.6 D
cs=map.contourf(x,y,plt_data,clevels,cmap=plt.cm.jet)#,clevels,cmap=plt.cm.jet)
map.colorbar(cs)
df = pd.read_excel('E:/bst_trc.xls',sheet_name='Sheet6')
colors = {'SuCS': 'red', 'ESCS': 'blue', 'SCS': 'green', 'D': 'black', 'VSCS': 'orange', 'DD':'cyan',
'CS': 'magenta'}
df['x'], df['y'] = map(list(df['Lon']), list(df['Lat']))
for grade in list(df['grade'].unique()):
ax.scatter(df[df['grade'] == grade]['x'],
df[df['grade'] == grade]['y'],
s = 50,
label = grade,
facecolors = colors[grade])
plt.plot(df['x'], df['y'], 'k-', lw = 1.5)
ax.legend(loc='upper center', bbox_to_anchor=(0.5, -0.05),
fancybox=True, shadow=True, ncol=7)
#plt.savefig('E:/Super_cyclone/Amphan/sst_bfr.tif', bbox_inches='tight', dpi=300)
plt.show()
【问题讨论】:
-
您好,您能以允许我们使用的格式分享您的数据吗?
-
@warped 喜欢你想要的数据...sst 数据或 lat long 值数据。
-
不工作的位 ;)
-
确定....我正在发布 lat long excel 数据。
-
您的数据文件只有 4 个,可能是陆地上的 5 个点。这就是你想要的吗?
标签: python python-3.x matplotlib data-visualization scatter-plot