如何根据强度用标记颜色绘制旋风的轨迹

how to plot the track of cyclone with marker colors according to intensity

我正在尝试在底图上绘制旋风的轨迹。我成功地用相同颜色的标记绘制它,我想要的是根据强度变化绘制标记。我将附上我能够使用相同颜色标记绘制轨道的代码部分。如果有人能在这方面帮助我根据强度绘制轨道,将不胜感激。
我的代码:

llons, llats = np.meshgrid(lons, lats)
x,y = map(llons,llats)
plt.style.use('seaborn-white')
clevels=[-1.6,-1.2,-0.8,-0.4,0.0,0.4,0.8]
cs = map.contourf(x,y,plt_data,clevels,cmap=plt.cm.jet)
#cs = map.contourf(x,y,plt_data,cmap=plt.cm.jet)
#CS2 = ax.contour(cs, levels=cs.levels, colors='k')
#ax.clabel(cs,inline=True, fontsize=10)
map.colorbar(cs)
####################track##########################
import pandas as pd
df = pd.read_excel('E:/bst_trc.xls',sheet_name='1990')
latitude = df.Latitude.values[0:25]
longitude = df.Longitude.values[0:25]
it = df.Grade.values[0:25]
x,y = map(longitude, latitude)
colors = {'SUCS':'red', 'ESCS':'blue', 'SCS':'green', 'D':'black','VSCS':'orange','DD':'cyan'}
plt.scatter(x,y, s=50,edgecolors="red", facecolors='none', linewidth=2)
plt.plot(x,y,'k',linewidth=1.5 )

此外,我附上经纬度和强度值:

使用您的数据和此代码:

import matplotlib.pyplot as plt
import pandas as pd
plt.style.use('seaborn-white')

df = pd.read_csv('data.csv')

colors = {'SUCS': 'red', 'ESCS': 'blue', 'SCS': 'green', 'D': 'black', 'VSCS': 'orange', 'DD': 'cyan', 'CS': 'magenta'}

fig, ax = plt.subplots(1, 1)

for grade in list(df['grade'].unique()):
    ax.scatter(df[df['grade'] == grade]['lon'],
               df[df['grade'] == grade]['lat'],
               s = 50,
               label = grade,
               facecolors = colors[grade])

plt.plot(df['lon'], df['lat'], 'k-', lw = 1)

ax.set_xlabel('Longitude')
ax.set_ylabel('Latitude')
ax.axis('equal')

plt.legend()
plt.show()

我得到了这个散点图:


如果您想将其重叠到地图上,请查看此代码:

import matplotlib.pyplot as plt
import pandas as pd
from mpl_toolkits.basemap import Basemap
plt.style.use('seaborn-white')

df = pd.read_csv('data.csv')

colors = {'SUCS': 'red', 'ESCS': 'blue', 'SCS': 'green', 'D': 'black', 'VSCS': 'orange', 'DD': 'cyan', 'CS': 'magenta'}

fig, ax = plt.subplots(1, 1)

m = Basemap(llcrnrlon = 75, llcrnrlat = 5, urcrnrlon = 90, urcrnrlat = 20, resolution = 'i', projection = 'merc')
m.drawcoastlines(color = 'black')

df['x'], df['y'] = m(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)

plt.legend()
plt.show()

给出这张地图:


如果你想要一个更简单的解决方案,你可以将上面代码中的for循环替换为:

import seaborn as sns
sns.scatterplot(data = df,
                x = 'x',
                y = 'y',
                hue = 'grade',
                s = 50)