python绘图
程序员文章站
2022-03-02 09:41:06
...
basemap 绘图
m = Basemap(
llcrnrlat=lat[0,0],urcrnrlat=lat[-1,-1],llcrnrlon=lon[0,0],urcrnrlon=lon[-1,-1],
resolution='i', area_thresh=1000.,
lat_0=37.,lon_0=102.,lat_1=25.,lat_2=50.,
projection='lcc')
cbar = m.colorbar(cs)
cbar.ax.tick_params(axis='y', direction='in',length=15,labelsize=15) #设置colorbar刻度线位置,长度,标签字体大小
调用NCL中color map
- 安装cmaps
pip install https://github.com/hhuangwx/cmaps/archive/master.zip
or:
git clone https://github.com/hhuangwx/cmaps.git
cd cmaps
python setup.py install
- 用法
import matplotlib.pyplot as plt
import cmaps
import numpy as np
x = y = np.arange(-3.0, 3.01, 0.05)
X, Y = np.meshgrid(x, y)
sigmax = sigmay = 1.0
mux = muy = sigmaxy=0.0
Xmu = X-mux
Ymu = Y-muy
rho = sigmaxy/(sigmax*sigmay)
z = Xmu**2/sigmax**2 + Ymu**2/sigmay**2 - 2*rho*Xmu*Ymu/(sigmax*sigmay)
denom = 2*np.pi*sigmax*sigmay*np.sqrt(1-rho**2)
Z = np.exp(-z/(2*(1-rho**2))) / denom
plt.pcolormesh(X,Y,Z,cmap=cmaps.WhiteBlueGreenYellowRed)
plt.colorbar()