画等温线图用python怎么把陆地填成灰色
时间: 2023-06-05 16:04:50 浏览: 370
画等温线.zip
对于您的问题,我可以为您提供如下Python代码:
```python
import cartopy.crs as ccrs
import cartopy.feature as cfeature
import matplotlib.pyplot as plt
import numpy as np
# Define the extent of the map
extent = [-180, 180, -90, 90]
# Create a figure and axis using PlateCarree projection
fig, ax = plt.subplots(subplot_kw={'projection': ccrs.PlateCarree()})
# Add coastlines and countries to the map
ax.add_feature(cfeature.COASTLINE)
ax.add_feature(cfeature.BORDERS)
# Set the colors for land and sea
land_color = [0.5, 0.5, 0.5]
ocean_color = [0.9, 0.9, 1]
# Draw the land and sea using the colors set above
ax.add_feature(cfeature.LAND, facecolor=land_color)
ax.add_feature(cfeature.OCEAN, facecolor=ocean_color)
# Show the plot
plt.show()
```
这段代码可以画出一个地图,其中陆地被填充为灰色。
我希望我的回答能够帮到您,如果您有其他问题,请随时问我。
阅读全文