matplotlib --> pcolormesh 只因 cartopy

Cartopy 地图中心点调试

:PT世界地图

import matplotlib.pyplot as plt
import cartopy.crs as ccrs
from cartopy.mpl.ticker import LatitudeFormatter, LongitudeFormatter


proj = ccrs.PlateCarree()
fig, ax = plt.subplots(1, 1, subplot_kw={'projection': proj})
ax.coastlines()
ax.set_xticks([-120, -60, 0, 60, 120, ], crs=proj)
ax.set_yticks([-80, -40, 0, 40, 80, ], crs=proj)
ax.xaxis.set_major_formatter(LongitudeFormatter())
ax.yaxis.set_major_formatter(LatitudeFormatter())
plt.show()

需要经度180°为中心点的需求地图

import matplotlib.pyplot as plt
import cartopy.crs as ccrs
from cartopy.mpl.ticker import LatitudeFormatter, LongitudeFormatter

proj = ccrs.PlateCarree(central_longitude=180)
fig, ax = plt.subplots(1, 1, subplot_kw={'projection': proj})
ax.coastlines()
ax.add_feature(cfeature.LAKES, edgecolor='black')
ax.set_xticks([0, 60, 120, 180, 240, 300, 360], crs=ccrs.PlateCarree(central_longitude=-180))
ax.set_yticks([-80, -40, 0, 40, 80], crs=ccrs.PlateCarree(central_longitude=180))
ax.xaxis.set_major_formatter(LongitudeFormatter())
ax.yaxis.set_major_formatter(LatitudeFormatter())
plt.show()

相关参数

.LAKES : 添加湖泊

....: 相关百度很多 此篇只介绍根据经度调整地图 及 x轴标度调整

central_longitude: 以多少度为中心点

matplotlib --> pcolormesh(伪色彩图)

import sys
import os
import matplotlib.pyplot as plt
from matplotlib import colors as cols
import numpy as np
import pandas as pd


arr = np.random.randint(0,100,size=(5,6))
x,y = np.arange(1,7),np.arange(1,6)
# todo 此处可以拼接色带 或者其他 cmap的颜色操作  norm 根据颜色数值索引
plt.pcolormesh(x,y,arr)
plt.show()

posted @ 2022-06-27 15:20  辻渃。  阅读(211)  评论(0)    收藏  举报