基于可变值的着色点

问题描述 投票:0回答:1

我有一个气象站网络上的温度值数据集。我希望将数据绘制在地图上,并根据站点的温度对点进行着色。在Python / Matplotlib中是否存在执行此操作的功能?

供参考:我的数据集在netCDF文件中,并且包含每个电台的经/纬度值。温度变量是测站和时间的函数。到目前为止,我已经使用Cartopy在地图上绘制了点,但是每个点只有一种颜色。

python matplotlib colors cartopy
1个回答
0
投票

您正在使用scatter参数寻找c绘图命令:

import cartopy.crs as ccrs
import cartopy.feature as cfeature
import matplotlib.pyplot as plt
import numpy as np

lon = np.random.rand(50) * 50 - 120
lat = np.random.rand(50) * 25 + 25
temps = np.random.randn(50) * 10 + 25

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1, projection=ccrs.LambertConformal())
ax.scatter(lon, lat, c=temps, transform=ccrs.PlateCarree())
ax.add_feature(cfeature.COASTLINE)
ax.add_feature(cfeature.BORDERS)
© www.soinside.com 2019 - 2024. All rights reserved.